python - How to run a single test case in nose2 -
i'd run single test contained in subclass of unittest.testcase using nose2 following how run specific test in nose2, doesn't seem work me. i'm using following example script, i've named mickey_mouse_test.py:
import unittest class testmickeymouse(unittest.testcase): def test_1plus1is2(self): self.asserttrue(1+1 == 2) def test_to_uppercase(self): self.assertequal("hello".upper(), "hello") if __name__ == "__main__": unittest.main() if run nose2 mickey_mouse_test in same directory, runs tests in module:
kurt@kurt-thinkpad:~/documents/scratch$ nose2 mickey_mouse_test .. ---------------------------------------------------------------------- ran 2 tests in 0.001s ok however, if try run test_to_uppercase error:
kurt@kurt-thinkpad:~/documents/scratch$ nose2 mickey_mouse_test.test_to_uppercase e ====================================================================== error: mickey_mouse_test.test_to_uppercase (nose2.loader.loadtestsfailure) ---------------------------------------------------------------------- attributeerror: module 'mickey_mouse_test' has no attribute 'test_to_uppercase' ---------------------------------------------------------------------- ran 1 test in 0.001s failed (errors=1) if use -s option still error, albeit different one:
kurt@kurt-thinkpad:~/documents/scratch$ nose2 -s mickey_mouse_test.test_to_uppercase e ====================================================================== error: mickey_mouse_test.test_to_uppercase (nose2.loader.loadtestsfailure) ---------------------------------------------------------------------- oserror: /home/kurt/documents/scratch/mickey_mouse_test.test_to_uppercase not directory ---------------------------------------------------------------------- ran 1 test in 0.000s failed (errors=1) i've tried reading "specifying tests run" section in http://nose2.readthedocs.io/en/latest/usage.html, in stated 'python object part' should 'dotted name'. don't see why in case, mickey_mouse_test.test_to_uppercase not 'dotted name'. ideas why not working?
here way run test_to_uppercase without using nose2 (following running single test unittest.testcase via command line):
kurt@kurt-thinkpad:~/documents/scratch$ python mickey_mouse_test.py testmickeymouse.test_to_uppercase . ---------------------------------------------------------------------- ran 1 test in 0.000s ok
Comments
Post a Comment