forked from vim-test/vim-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpytest_spec.vim
150 lines (109 loc) · 3.44 KB
/
pytest_spec.vim
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
source spec/support/helpers.vim
describe "PyTest_xunit"
" using xunit as a testing framework (unittest.*)
before
let g:test#python#runner = 'pytest'
cd spec/fixtures/nose
end
after
call Teardown()
cd -
end
it "runs nearest tests"
view +1 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestNumbers'
view +2 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestNumbers::test_numbers'
view +7 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestSubclass::test_subclass'
view +9 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::Test_underscores_and_123'
view +11 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::Test_underscores_and_123::test_underscores'
view +13 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::UnittestClass'
view +19 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::SomeTest::test_foo'
view +1 test_method.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_method.py::test_numbers'
end
" it "runs nearest tests ignoring nested classes"
" view +6 test_method.py
" TestNearest
"
" Expect g:test#last_command == 'python -m pytest test_method.py::test_foo'
" end
it "runs file test if nearest test couldn't be found"
view +1 test_method.py
normal O
TestNearest
Expect g:test#last_command == 'python -m pytest test_method.py'
end
it "runs class tests"
view +5 test_class.py
TestClass
Expect g:test#last_command == 'python -m pytest test_class.py::TestSubclass'
view +6 test_class.py
TestClass
Expect g:test#last_command == 'python -m pytest test_class.py::TestSubclass'
end
it "runs file tests"
view test_class.py
TestFile
Expect g:test#last_command == 'python -m pytest test_class.py'
end
it "runs test suites"
view test_class.py
TestSuite
Expect g:test#last_command == 'python -m pytest'
end
end
describe "Pytest"
" using pytest as a testing framework instead of xunit (unittest.*)
before
let g:test#python#runner = 'pytest'
cd spec/fixtures/pytest
end
after
call Teardown()
cd -
end
it ":TestNearest (class)"
view +1 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestClass'
end
it ":TestNearest (nested-class)"
view +2 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestClass::TestNestedClass'
end
it ":TestNearest (nested-class-method)"
view +3 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestClass::TestNestedClass::test_nestedclass_method'
end
it ":TestNearest (method)"
view +6 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::TestClass::test_method'
end
it ":TestNearest (function)"
view +10 test_class.py
TestNearest
Expect g:test#last_command == 'python -m pytest test_class.py::test_function'
end
it ":TestClass (function)"
view +15 test_class.py
TestClass
Expect g:test#last_command == 'python -m pytest test_class.py::TestClass2'
end
end