| 12 |
|
def test_anytest(self):
|
| 13 |
|
|
| 14 |
|
def exact_file_a(filename, modname, funcname):
|
| 15 |
|
if filename is None:
|
| 16 |
|
return None
|
| 17 |
|
return filename == '/a/file.py'
|
| 18 |
|
|
| 19 |
|
def exact_file_b(filename, modname, funcname):
|
| 20 |
|
if filename is None:
|
| 21 |
|
return None
|
| 22 |
|
return filename == '/a/nother/file.py'
|
| 23 |
|
|
| 24 |
|
def exact_module_a(filename, modname, funcname):
|
| 25 |
|
if modname is None:
|
| 26 |
|
return None
|
| 27 |
|
return modname == 'some.module'
|
| 28 |
|
|
| 29 |
|
def exact_module_b(filename, modname, funcname):
|
| 30 |
|
if modname is None:
|
| 31 |
|
return None
|
| 32 |
|
return modname == 'some.other.module'
|
| 33 |
|
|
| 34 |
|
c = Config()
|
| 35 |
|
s = Selector(c)
|
| 36 |
|
s.tests = [ '/a/file.py', 'some.module' ]
|
| 37 |
|
|
| 38 |
|
# in these cases, there is a test that doesn't care
|
| 39 |
|
# so they all pass
|
| 40 |
|
assert s.anytest(exact_file_a)
|
| 41 |
|
assert s.anytest(exact_file_b)
|
| 42 |
|
assert s.anytest(exact_module_a)
|
| 43 |
|
assert s.anytest(exact_module_b)
|
| 44 |
|
|
| 45 |
|
# no test matches file b
|
| 46 |
|
s.tests = [ '/a/file.py' ]
|
| 47 |
|
assert s.anytest(exact_file_a)
|
| 48 |
|
assert not s.anytest(exact_file_b)
|
| 49 |
|
assert s.anytest(exact_module_a)
|
| 50 |
|
assert s.anytest(exact_module_b)
|
| 51 |
|
|
| 52 |
|
s.tests = [ '/a/file.py', '/that/file.py' ]
|
| 53 |
|
assert s.anytest(exact_file_a)
|
| 54 |
|
assert not s.anytest(exact_file_b)
|
| 55 |
|
assert s.anytest(exact_module_a)
|
| 56 |
|
assert s.anytest(exact_module_b)
|
| 57 |
|
|
| 58 |
|
# no test matches module b
|
| 59 |
|
s.tests = [ 'some.module' ]
|
| 60 |
|
assert s.anytest(exact_file_a)
|
| 61 |
|
assert s.anytest(exact_file_b)
|
| 62 |
|
assert s.anytest(exact_module_a)
|
| 63 |
|
assert not s.anytest(exact_module_b)
|
| 64 |
|
|
| 65 |
|
# no test matches module b
|
| 66 |
|
s.tests = [ 'some.module', 'blah.blah' ]
|
| 67 |
|
assert s.anytest(exact_file_a)
|
| 68 |
|
assert s.anytest(exact_file_b)
|
| 69 |
|
assert s.anytest(exact_module_a)
|
| 70 |
|
assert not s.anytest(exact_module_b)
|
| 71 |
|
|
| |
13 |
def tearDown(self):
|
| |
14 |
logging.getLogger('nose.selector').setLevel(logging.WARN)
|
| |
15 |
|
| 117 |
|
s.tests = [ ':Bar' ]
|
| 118 |
|
assert s.wantClass(Bar)
|
| 119 |
|
assert not s.wantClass(Foo)
|
| 120 |
|
assert not s.wantClass(TestMe)
|
| 121 |
|
|
| 122 |
|
s.tests = [ ':Bar.baz' ]
|
| 123 |
|
assert s.wantClass(Bar)
|
| 124 |
|
assert not s.wantClass(Foo)
|
| 125 |
|
assert not s.wantClass(TestMe)
|
| 126 |
|
|
| 127 |
|
s.tests = [ ':Blah' ]
|
| 128 |
|
assert not s.wantClass(Bar)
|
| 129 |
|
assert not s.wantClass(Foo)
|
| 130 |
|
assert not s.wantClass(TestMe)
|
| 131 |
|
|
| 132 |
|
s.tests = [ ':Blah.baz' ]
|
| 133 |
|
assert not s.wantClass(Bar)
|
| 134 |
|
assert not s.wantClass(Foo)
|
| 135 |
|
assert not s.wantClass(TestMe)
|
| 136 |
|
|
| 137 |
|
s.tests = [ __name__ ]
|
| 138 |
|
assert s.wantClass(Bar) == [None]
|
| 139 |
|
assert s.wantClass(Foo) is None
|
| 140 |
|
assert s.wantClass(TestMe) == [None]
|
| 141 |
|
|
| 142 |
|
s.tests = [ __file__ ]
|
| 143 |
|
assert s.wantClass(Bar) == [None]
|
| 144 |
|
assert s.wantClass(Foo) is None
|
| 145 |
|
assert s.wantClass(TestMe) == [None]
|
| |
61 |
tests = test_addr([ ':Bar' ])
|
| |
62 |
assert s.wantClass(Bar, tests)
|
| |
63 |
assert not s.wantClass(Foo, tests)
|
| |
64 |
assert not s.wantClass(TestMe, tests)
|
| |
65 |
|
| |
66 |
tests = test_addr([ ':Bar.baz' ])
|
| |
67 |
assert s.wantClass(Bar, tests)
|
| |
68 |
assert not s.wantClass(Foo, tests)
|
| |
69 |
assert not s.wantClass(TestMe, tests)
|
| |
70 |
|
| |
71 |
tests = test_addr([ ':Blah' ])
|
| |
72 |
assert not s.wantClass(Bar, tests)
|
| |
73 |
assert not s.wantClass(Foo, tests)
|
| |
74 |
assert not s.wantClass(TestMe, tests)
|
| |
75 |
|
| |
76 |
tests = test_addr([ ':Blah.baz' ])
|
| |
77 |
assert not s.wantClass(Bar, tests)
|
| |
78 |
assert not s.wantClass(Foo, tests)
|
| |
79 |
assert not s.wantClass(TestMe, tests)
|
| |
80 |
|
| |
81 |
tests = test_addr([ __name__ ])
|
| |
82 |
assert s.wantClass(Bar, tests)
|
| |
83 |
assert not s.wantClass(Foo, tests)
|
| |
84 |
assert s.wantClass(TestMe, tests)
|
| |
85 |
|
| |
86 |
tests = test_addr([ __file__ ])
|
| |
87 |
assert s.wantClass(Bar, tests)
|
| |
88 |
assert not s.wantClass(Foo, tests)
|
| |
89 |
assert s.wantClass(TestMe, tests)
|
| 194 |
|
s.tests = [ 'a.module' ]
|
| 195 |
|
assert not s.wantFile('test.py')
|
| 196 |
|
assert not s.wantFile('foo/test_foo.py')
|
| 197 |
|
assert not s.wantFile('test-dir/test.py', package='baz')
|
| 198 |
|
assert not s.wantFile('other/file.txt')
|
| 199 |
|
assert s.wantFile('/path/to/a/module.py')
|
| 200 |
|
assert s.wantFile('/another/path/to/a/module/file.py')
|
| 201 |
|
assert not s.wantFile('/path/to/a/module/data/file.txt')
|
| |
146 |
tests = test_addr([ 'a.module' ], base)
|
| |
147 |
assert not s.wantFile(os.path.join(base, 'test.py'),
|
| |
148 |
tests=tests)
|
| |
149 |
assert not s.wantFile(os.path.join(base, 'foo/test_foo.py'),
|
| |
150 |
tests=tests)
|
| |
151 |
assert not s.wantFile(os.path.join(base, 'test-dir/test.py'),
|
| |
152 |
package='baz', tests=tests)
|
| |
153 |
assert not s.wantFile(os.path.join(base, 'other/file.txt'),
|
| |
154 |
tests=tests)
|
| |
155 |
assert s.wantFile('/path/to/a/module.py', tests=tests)
|
| |
156 |
assert s.wantFile('/another/path/to/a/module/file.py', tests=tests)
|
| |
157 |
assert not s.wantFile('/path/to/a/module/data/file.txt', tests=tests)
|
| 216 |
|
s.tests = [ ':test_bar' ]
|
| 217 |
|
assert s.wantFunction(test_bar)
|
| 218 |
|
assert not s.wantFunction(test_foo)
|
| 219 |
|
assert not s.wantFunction(foo)
|
| 220 |
|
|
| 221 |
|
s.tests = [ __file__ ]
|
| 222 |
|
assert s.wantFunction(test_bar)
|
| 223 |
|
assert s.wantFunction(test_foo)
|
| 224 |
|
assert not s.wantFunction(foo)
|
| |
172 |
tests = test_addr([ ':test_bar' ])
|
| |
173 |
assert s.wantFunction(test_bar, tests)
|
| |
174 |
assert not s.wantFunction(test_foo, tests)
|
| |
175 |
assert not s.wantFunction(foo, tests)
|
| |
176 |
|
| |
177 |
tests = test_addr([ __file__ ])
|
| |
178 |
assert s.wantFunction(test_bar, tests)
|
| |
179 |
assert s.wantFunction(test_foo, tests)
|
| |
180 |
assert not s.wantFunction(foo, tests)
|
| 241 |
|
s.tests = [ ':Baz.test_too' ]
|
| 242 |
|
assert s.wantMethod(Baz.test_too)
|
| 243 |
|
assert not s.wantMethod(Baz.test_me)
|
| 244 |
|
assert not s.wantMethod(Baz.other)
|
| 245 |
|
|
| 246 |
|
s.tests = [ ':Baz' ]
|
| 247 |
|
assert s.wantMethod(Baz.test_too)
|
| 248 |
|
assert s.wantMethod(Baz.test_me)
|
| 249 |
|
assert not s.wantMethod(Baz.other)
|
| 250 |
|
|
| 251 |
|
s.tests = [ ':Spaz' ]
|
| 252 |
|
assert not s.wantMethod(Baz.test_too)
|
| 253 |
|
assert not s.wantMethod(Baz.test_me)
|
| 254 |
|
assert not s.wantMethod(Baz.other)
|
| |
197 |
tests = test_addr([ ':Baz.test_too' ])
|
| |
198 |
assert s.wantMethod(Baz.test_too, tests)
|
| |
199 |
assert not s.wantMethod(Baz.test_me, tests)
|
| |
200 |
assert not s.wantMethod(Baz.other, tests)
|
| |
201 |
|
| |
202 |
tests = test_addr([ ':Baz' ])
|
| |
203 |
assert s.wantMethod(Baz.test_too, tests)
|
| |
204 |
assert s.wantMethod(Baz.test_me, tests)
|
| |
205 |
assert not s.wantMethod(Baz.other, tests)
|
| |
206 |
|
| |
207 |
tests = test_addr([ ':Spaz' ])
|
| |
208 |
assert not s.wantMethod(Baz.test_too, tests)
|
| |
209 |
assert not s.wantMethod(Baz.test_me, tests)
|
| |
210 |
assert not s.wantMethod(Baz.other, tests)
|
| 276 |
|
s.tests = [ 'this.that.another' ]
|
| 277 |
|
assert not s.wantModule(m)
|
| 278 |
|
assert s.wantModule(m2)
|
| 279 |
|
assert s.wantModule(m3)
|
| 280 |
|
assert s.wantModule(m4)
|
| 281 |
|
assert not s.wantModule(m5)
|
| 282 |
|
assert not s.wantModule(m6)
|
| 283 |
|
assert not s.wantModule(m7)
|
| 284 |
|
assert not s.wantModule(m8)
|
| |
232 |
tests = test_addr([ 'this.that.another' ])
|
| |
233 |
assert not s.wantModule(m, tests)
|
| |
234 |
assert s.wantModule(m2, tests)
|
| |
235 |
assert s.wantModule(m3, tests)
|
| |
236 |
assert s.wantModule(m4, tests)
|
| |
237 |
assert not s.wantModule(m5, tests)
|
| |
238 |
assert not s.wantModule(m6, tests)
|
| |
239 |
assert not s.wantModule(m7, tests)
|
| |
240 |
assert not s.wantModule(m8, tests)
|
| 306 |
|
s.tests = [ 'this.that.another' ]
|
| 307 |
|
assert not s.wantModuleTests(m)
|
| 308 |
|
assert not s.wantModuleTests(m2)
|
| 309 |
|
assert s.wantModuleTests(m3)
|
| 310 |
|
assert s.wantModuleTests(m4)
|
| 311 |
|
assert not s.wantModuleTests(m5)
|
| 312 |
|
assert not s.wantModuleTests(m6)
|
| 313 |
|
assert not s.wantModuleTests(m7)
|
| 314 |
|
assert not s.wantModuleTests(m8)
|
| |
262 |
tests = test_addr([ 'this.that.another' ])
|
| |
263 |
assert not s.wantModuleTests(m, tests)
|
| |
264 |
assert not s.wantModuleTests(m2, tests)
|
| |
265 |
assert s.wantModuleTests(m3, tests)
|
| |
266 |
assert s.wantModuleTests(m4, tests)
|
| |
267 |
assert not s.wantModuleTests(m5, tests)
|
| |
268 |
assert not s.wantModuleTests(m6, tests)
|
| |
269 |
assert not s.wantModuleTests(m7, tests)
|
| |
270 |
assert not s.wantModuleTests(m8, tests)
|
| 326 |
|
s.tests = [ 'what' ]
|
| 327 |
|
assert s.moduleInTests(w)
|
| 328 |
|
assert s.moduleInTests(w, True)
|
| 329 |
|
assert s.moduleInTests(w_e)
|
| 330 |
|
assert s.moduleInTests(w_e, True)
|
| 331 |
|
assert s.moduleInTests(w_n)
|
| 332 |
|
assert s.moduleInTests(w_n, True)
|
| 333 |
|
assert not s.moduleInTests(we)
|
| 334 |
|
assert not s.moduleInTests(we, True)
|
| 335 |
|
assert not s.moduleInTests(f_e)
|
| 336 |
|
assert not s.moduleInTests(f_e, True)
|
| 337 |
|
|
| 338 |
|
s.tests = [ 'what.ever' ]
|
| 339 |
|
assert not s.moduleInTests(w)
|
| 340 |
|
assert s.moduleInTests(w, True)
|
| 341 |
|
assert s.moduleInTests(w_e)
|
| 342 |
|
assert s.moduleInTests(w_e, True)
|
| 343 |
|
assert not s.moduleInTests(w_n)
|
| 344 |
|
assert not s.moduleInTests(w_n, True)
|
| 345 |
|
assert not s.moduleInTests(we)
|
| 346 |
|
assert not s.moduleInTests(we, True)
|
| 347 |
|
assert not s.moduleInTests(f_e)
|
| 348 |
|
assert not s.moduleInTests(f_e, True)
|
| 349 |
|
|
| 350 |
|
s.tests = [ 'what.ever', 'what.not' ]
|
| 351 |
|
assert not s.moduleInTests(w)
|
| 352 |
|
assert s.moduleInTests(w, True)
|
| 353 |
|
assert s.moduleInTests(w_e)
|
| 354 |
|
assert s.moduleInTests(w_e, True)
|
| 355 |
|
assert s.moduleInTests(w_n)
|
| 356 |
|
assert s.moduleInTests(w_n, True)
|
| 357 |
|
assert not s.moduleInTests(we)
|
| 358 |
|
assert not s.moduleInTests(we, True)
|
| 359 |
|
assert not s.moduleInTests(f_e)
|
| 360 |
|
assert not s.moduleInTests(f_e, True)
|
| |
282 |
tests = test_addr([ 'what' ])
|
| |
283 |
assert s.moduleInTests(tests)(w)
|
| |
284 |
assert s.moduleInTests(tests, True)(w)
|
| |
285 |
assert s.moduleInTests(tests)(w_e)
|
| |
286 |
assert s.moduleInTests(tests, True)(w_e)
|
| |
287 |
assert s.moduleInTests(tests)(w_n)
|
| |
288 |
assert s.moduleInTests(tests, True)(w_n)
|
| |
289 |
assert not s.moduleInTests(tests)(we)
|
| |
290 |
assert not s.moduleInTests(tests, True)(we)
|
| |
291 |
assert not s.moduleInTests(tests)(f_e)
|
| |
292 |
assert not s.moduleInTests(tests, True)(f_e)
|
| |
293 |
|
| |
294 |
tests = test_addr([ 'what.ever' ])
|
| |
295 |
assert not s.moduleInTests(tests)(w)
|
| |
296 |
assert s.moduleInTests(tests, True)(w)
|
| |
297 |
assert s.moduleInTests(tests)(w_e)
|
| |
298 |
assert s.moduleInTests(tests, True)(w_e)
|
| |
299 |
assert not s.moduleInTests(tests)(w_n)
|
| |
300 |
assert not s.moduleInTests(tests, True)(w_n)
|
| |
301 |
assert not s.moduleInTests(tests)(we)
|
| |
302 |
assert not s.moduleInTests(tests, True)(we)
|
| |
303 |
assert not s.moduleInTests(tests)(f_e)
|
| |
304 |
assert not s.moduleInTests(tests, True)(f_e)
|
| |
305 |
|
| |
306 |
tests = test_addr([ 'what.ever', 'what.not' ])
|
| |
307 |
assert not s.moduleInTests(tests)(w)
|
| |
308 |
assert s.moduleInTests(tests, True)(w)
|
| |
309 |
assert s.moduleInTests(tests)(w_e)
|
| |
310 |
assert s.moduleInTests(tests, True)(w_e)
|
| |
311 |
assert s.moduleInTests(tests)(w_n)
|
| |
312 |
assert s.moduleInTests(tests, True)(w_n)
|
| |
313 |
assert not s.moduleInTests(tests)(we)
|
| |
314 |
assert not s.moduleInTests(tests, True)(we)
|
| |
315 |
assert not s.moduleInTests(tests)(f_e)
|
| |
316 |
assert not s.moduleInTests(tests, True)(f_e)
|
| 373 |
|
s.tests = [ 'test.py' ]
|
| 374 |
|
assert not s.moduleInTests(f)
|
| 375 |
|
assert s.moduleInTests(t)
|
| 376 |
|
assert not s.moduleInTests(f_t_f)
|
| 377 |
|
assert not s.moduleInTests(d_t_t)
|
| 378 |
|
|
| 379 |
|
s.tests = [ 'foo/' ]
|
| 380 |
|
assert s.moduleInTests(f)
|
| 381 |
|
assert s.moduleInTests(f_t_f)
|
| 382 |
|
assert not s.moduleInTests(t)
|
| 383 |
|
assert not s.moduleInTests(d_t_t)
|
| 384 |
|
|
| 385 |
|
s.tests = [ 'foo/test_foo.py' ]
|
| 386 |
|
assert not s.moduleInTests(f)
|
| 387 |
|
assert s.moduleInTests(f_t_f)
|
| 388 |
|
assert not s.moduleInTests(t)
|
| 389 |
|
assert not s.moduleInTests(d_t_t)
|
| 390 |
|
|
| 391 |
|
s.tests = [ 'test-dir/test.py' ]
|
| 392 |
|
assert not s.moduleInTests(f)
|
| 393 |
|
assert not s.moduleInTests(t)
|
| 394 |
|
assert not s.moduleInTests(f_t_f)
|
| 395 |
|
assert s.moduleInTests(d_t_t)
|
| |
329 |
tests = test_addr([ 'test.py' ], base)
|
| |
330 |
assert not s.moduleInTests(tests)(f)
|
| |
331 |
assert s.moduleInTests(tests)(t)
|
| |
332 |
assert not s.moduleInTests(tests)(f_t_f)
|
| |
333 |
assert not s.moduleInTests(tests)(d_t_t)
|
| |
334 |
|
| |
335 |
tests = test_addr([ 'foo/' ], base)
|
| |
336 |
assert s.moduleInTests(tests)(f)
|
| |
337 |
assert s.moduleInTests(tests)(f_t_f)
|
| |
338 |
assert not s.moduleInTests(tests)(t)
|
| |
339 |
assert not s.moduleInTests(tests)(d_t_t)
|
| |
340 |
|
| |
341 |
tests = test_addr([ 'foo/test_foo.py' ], base)
|
| |
342 |
assert not s.moduleInTests(tests)(f)
|
| |
343 |
assert s.moduleInTests(tests)(f_t_f)
|
| |
344 |
assert not s.moduleInTests(tests)(t)
|
| |
345 |
assert not s.moduleInTests(tests)(d_t_t)
|
| |
346 |
|
| |
347 |
tests = test_addr([ 'test-dir/test.py' ], base)
|
| |
348 |
assert not s.moduleInTests(tests)(f)
|
| |
349 |
assert not s.moduleInTests(tests)(t)
|
| |
350 |
assert not s.moduleInTests(tests)(f_t_f)
|
| |
351 |
assert s.moduleInTests(tests)(d_t_t)
|