A list of options for the nosetests command of the python unit test tool Nose. Although it is called a list, I was exhausted on the way, so it is my own discretion, but it is arranged from the top in the order of frequent use. I can't put the basic usage.
Perform all file test cases that match the nose naming convention
nosetests
nosetests test_settings.py
nosetests test_settings.py #Run tests in a specific file
nosetests test_settings.py:SettingsApiTestCase #Run tests in a particular class in a particular file
nosetests test_settings.py:SettingsApiTestCase.test_get_settings #Run tests for specific methods in specific classes in specific files
nosetests --failed
Specify the number of startup processes.
nosetests --processes=4
The default is 10 seconds
nosetests --process-timeout=10
In the example below, if you put print ()
in test_settings.py, the contents will be output.
nosetests test_settings.py -s
nosetests sample_test.py -v
nosetests sample_test.py --verbosity=2
nosetests test_settings.py -q
Use it with the -v
option to output all test case names.
nosetests --collect-only -v
In the case of the example below, test_settings.py under ./tests/
will be executed.
nosetests test_settings.py -w ./tests/
Read .noserc or nose.cfg in home directory by default. Option to specify this. To prevent reading anything ʻexport NOSE_IGNORE_CONFIG_FILES = 1`
nosetests test_settings.py -c ./config.ini
Specify multiple test files separated by commas
nosetests --tests=test_settings.py,test_login.py
nosetests test_settings.py test_login.py #This is the same
By default, ((?: ^ | \ B_ \ .-]) [Tt] est)
is specified, so files starting with test
etc. are executed. In the example below, test_settings.py
will be executed.
nosetests -m .*setting.*
In the example below test_settings.py will not be executed
nosetests -I .*setting.*
In the example below, test case test_get_settings1 is skipped and test_get_settings2 is executed
nosetests -e .*settings1.*
In the example below, since -m aaaaaaaaaaaaa.py
is executed, only the one that exactly matches ʻaaaaaaaaaaaaa.py is executed, but since
-i. * Setting. * `Is specified, test_settings.py Will be executed
nosetests -m aaaaaaaaaaaaa.py -i .*setting.*
nosetests -x
If you add @ unittest.skip ("skipping this one ")
etc., the test case will be skipped, but I think it is an option to prevent this from being skipped, but if you execute it, the skip itself will be skipped and when the test result is displayed It seems that ʻOK (SKIP = 1) just becomes ʻOK
? ?? ??
nosetests test_settings.py --no-skip
Recommended Posts