|
2 | 2 | (require 'pyimport)
|
3 | 3 | (require 'shut-up)
|
4 | 4 |
|
5 |
| -(ert-deftest var-extraction () |
| 5 | +(ert-deftest pyimport-var-extraction () |
6 | 6 | "Ensure we parse pyflakes output for older pyflakes versions."
|
7 | 7 | (should
|
8 | 8 | (equal
|
9 | 9 | (pyimport--extract-unused-var "'foo' imported but unused")
|
10 | 10 | "foo")))
|
11 | 11 |
|
12 |
| -(ert-deftest var-extraction-new () |
| 12 | +(ert-deftest pyimport-var-extraction-new () |
13 | 13 | "Ensure we parse pyflakes output for recent pyflakes versions."
|
14 | 14 | (should
|
15 | 15 | (equal
|
16 | 16 | (pyimport--extract-unused-var "'foo.bar' imported but unused")
|
17 | 17 | "bar")))
|
18 | 18 |
|
19 |
| -(ert-deftest remove-import-case-sensitive () |
| 19 | +(ert-deftest pyimport-remove-import-case-sensitive () |
20 | 20 | "Ensure we remove imports case-sensitively"
|
21 | 21 | (with-temp-buffer
|
22 | 22 | (insert "import cPickle as pickle")
|
23 | 23 | (pyimport--remove-import 1 "pickle")
|
24 | 24 | (should
|
25 | 25 | (equal (buffer-string) ""))))
|
26 | 26 |
|
27 |
| -(ert-deftest remove-import-extra-whitespace () |
| 27 | +(ert-deftest pyimport-remove-import-extra-whitespace () |
28 | 28 | "Ensure we remove imports correctly even when there's extra whitespace."
|
29 | 29 | (with-temp-buffer
|
30 | 30 | (insert "from foo import bar")
|
31 | 31 | (pyimport--remove-import 1 "bar")
|
32 | 32 | (should
|
33 | 33 | (equal (buffer-string) ""))))
|
34 | 34 |
|
35 |
| -(ert-deftest remove-import-as () |
| 35 | +(ert-deftest pyimport-remove-import-as () |
36 | 36 | "Ensure we remove imports correctly when there are aliases."
|
37 | 37 | (with-temp-buffer
|
38 | 38 | (insert "from foo import bar as newname")
|
39 | 39 | (pyimport--remove-import 1 "newname")
|
40 | 40 | (should
|
41 | 41 | (equal (buffer-string) ""))))
|
42 | 42 |
|
43 |
| -(ert-deftest remove-import-as-alias () |
| 43 | +(ert-deftest pyimport-remove-import-as-alias () |
44 | 44 | "Ensure we remove imports correctly when there are aliases."
|
45 | 45 | (with-temp-buffer
|
46 | 46 | (insert "import foo.bar as bar")
|
47 | 47 | (pyimport--remove-import 1 "bar")
|
48 | 48 | (should
|
49 | 49 | (equal (buffer-string) ""))))
|
50 | 50 |
|
51 |
| -(ert-deftest remove-on-line-first () |
| 51 | +(ert-deftest pyimport-remove-on-line-first () |
52 | 52 | "We should remove the first occurrence, if present."
|
53 | 53 | (with-temp-buffer
|
54 | 54 | (insert "foo bar baz bar")
|
55 | 55 | (pyimport--remove-on-line "bar")
|
56 | 56 | (should
|
57 | 57 | (equal (buffer-string) "foo baz bar"))))
|
58 | 58 |
|
59 |
| -(ert-deftest import-lines () |
| 59 | +(ert-deftest pyimport-import-lines () |
60 | 60 | (with-temp-buffer
|
61 | 61 | (insert "from foo import bar\n"
|
62 | 62 | "import baz\n"
|
|
68 | 68 | "import baz"
|
69 | 69 | "import quz.zox")))))
|
70 | 70 |
|
71 |
| -(ert-deftest import-lines-correct-buffer () |
| 71 | +(ert-deftest pyimport-import-lines-correct-buffer () |
72 | 72 | "Ensure we extract lines from the buffer passed in."
|
73 | 73 | (let ((buf (get-buffer-create "my-buffer")))
|
74 | 74 | (with-current-buffer buf
|
|
81 | 81 | (should (equal (get-text-property 0 'pyimport-path (-first-item lines))
|
82 | 82 | "my-buffer")))))))
|
83 | 83 |
|
84 |
| -(ert-deftest extract-unused-var () |
| 84 | +(ert-deftest pyimport-extract-unused-var () |
85 | 85 | (should
|
86 | 86 | (equal
|
87 | 87 | (pyimport--extract-unused-var "'foo' imported but unused")
|
|
95 | 95 | (pyimport--extract-unused-var "'foo.bar as xxx' imported but unused")
|
96 | 96 | "xxx")))
|
97 | 97 |
|
98 |
| -(ert-deftest same-module () |
| 98 | +(ert-deftest pyimport-same-module () |
99 | 99 | (should
|
100 | 100 | (pyimport--same-module
|
101 | 101 | "from foo import x"
|
|
105 | 105 | "from foo import x"
|
106 | 106 | "from foo.bar import x"))))
|
107 | 107 |
|
108 |
| -(ert-deftest buffers-in-mode () |
| 108 | +(ert-deftest pyimport-buffers-in-mode () |
109 | 109 | (let ((buf1 (get-buffer-create "buf1"))
|
110 | 110 | (buf2 (get-buffer-create "buf2")))
|
111 | 111 | (shut-up
|
|
123 | 123 | (kill-buffer buf1)
|
124 | 124 | (kill-buffer buf2)))
|
125 | 125 |
|
126 |
| -(ert-deftest for-each-line () |
| 126 | +(ert-deftest pyimport-for-each-line () |
127 | 127 | (let (result-lines)
|
128 | 128 | (with-temp-buffer
|
129 | 129 | (insert "a\nb\nc\nd")
|
|
134 | 134 | (should
|
135 | 135 | (equal result-lines '("a" "b" "c" "d")))))
|
136 | 136 |
|
137 |
| -(ert-deftest insert-import-simple () |
| 137 | +(ert-deftest pyimport-insert-import-simple () |
138 | 138 | "Test inserting an import."
|
139 | 139 | (with-temp-buffer
|
140 | 140 | (pyimport--insert-import "from foo import x")
|
141 | 141 | (should
|
142 | 142 | (equal (buffer-string)
|
143 | 143 | "from foo import x\n"))))
|
144 | 144 |
|
145 |
| -(ert-deftest insert-import-with-existing () |
| 145 | +(ert-deftest pyimport-insert-import-with-existing () |
146 | 146 | "Test inserting an import when we already have imports from that module."
|
147 | 147 | (with-temp-buffer
|
148 | 148 | (insert "from foo import x\n")
|
|
151 | 151 | (equal (buffer-string)
|
152 | 152 | "from foo import x, y\n"))))
|
153 | 153 |
|
154 |
| -(ert-deftest insert-import-duplicate () |
| 154 | +(ert-deftest pyimport-insert-import-duplicate () |
155 | 155 | "Test inserting an import when we already have that symbol imported"
|
156 | 156 | (with-temp-buffer
|
157 | 157 | (insert "from foo import x\n")
|
|
160 | 160 | (equal (buffer-string)
|
161 | 161 | "from foo import x\n"))))
|
162 | 162 |
|
163 |
| -(ert-deftest extract-simple-import () |
| 163 | +(ert-deftest pyimport-extract-simple-import () |
164 | 164 | (should
|
165 | 165 | (equal
|
166 | 166 | (pyimport--extract-simple-import "from foo import bar, xxx" "bar")
|
|
0 commit comments