forked from jorgenschaefer/elpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
elpy-format-code-test.el
65 lines (54 loc) · 1.67 KB
/
elpy-format-code-test.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(ert-deftest elpy-should-format-code-with-default-formatter ()
(elpy-testcase ()
(set-buffer-string-with-point
"_|_y= 2"
"z=3"
"x = 3")
(elpy-format-code)
(should
(buffer-be
"_|_y = 2"
"z = 3"
"x = 3"
))))
(ert-deftest elpy-should-format-code-with-yapf-formatter ()
(let ((elpy-formatter 'yapf)
backend-called)
(elpy-testcase ()
(set-buffer-string-with-point
"_|_y= 2"
"z=3"
"x = 3")
(mletf* ((elpy-yapf-fix-code ()
(setq backend-called "yapf")))
(call-interactively 'elpy-format-code))
(should (string= backend-called "yapf"))
)))
(ert-deftest elpy-should-format-code-with-autopep8-formatter ()
(let ((elpy-formatter 'autopep8)
backend-called)
(elpy-testcase ()
(set-buffer-string-with-point
"_|_y= 2"
"z=3"
"x = 3")
(mletf* ((elpy-autopep8-fix-code ()
(setq backend-called "autopep8")))
(call-interactively 'elpy-format-code))
(should (string= backend-called "autopep8"))
)))
(ert-deftest elpy-should-format-code-with-black-formatter ()
(let ((elpy-formatter 'black)
backend-called)
(elpy-testcase ()
(set-buffer-string-with-point
"_|_y= 2"
"z=3"
"x = 3")
(mletf* ((elpy-black-fix-code ()
(setq backend-called "black"))
(elpy-config--package-available-p (formatter)
t))
(call-interactively 'elpy-format-code))
(should (string= backend-called "black"))
)))