Nose plugin to randomly order tests and control random.seed.
Nose plugin to randomly order tests and control random.seed. (Also available for pytest).
All of these features are on by default but can be disabled with flags.
Randomness in testing can be quite powerful to discover hidden flaws in the tests themselves, as well as giving a little more coverage to your system.
By randomly ordering the tests, the risk of surprising inter-test dependencies is reduced - a technique used in many places, for example Google’s C++ test runner googletest.
By resetting the random seed to a repeatable number for each test, tests can create data based on random numbers and yet remain repeatable, for example factory boy’s fuzzy values. This is good for ensuring that tests specify the data they need and that the tested system is not affected by any data that is filled in randomly due to not being specified.
Install from pip with:
pip install nose-randomly
Nose will automatically find the plugin.
To activate it on your test run, use the --with-randomly flag, for example:
nosetests -v --with-randomly
The output will start with an extra line that tells you the random seed that is being used:
Using --randomly-seed=1234 test_D (abcd_tests.Tests) ... ok ...
If the tests then fail due to ordering or randomly created data, you can then restart them with that seed:
nosetests -v --with-randomly --randomly-seed=1234
You can disable behaviours you don’t like with the following flags:
nose has an unmerged pull request from 2009 to add
random ordering functionality. This is available in plugin format in the
nose-randomize package. It
works quite well but I found that since it replaces all of the test loading
nose, it can interact badly with other plugins. This plugin
was developed as a thinner layer to achieve the same thing, plus the random
seed resetting which was not available before.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|nose_randomly-1.2.5-py2.py3-none-any.whl (11.1 kB) Copy SHA256 Checksum SHA256||2.7||Wheel||Oct 28, 2016|
|nose-randomly-1.2.5.tar.gz (9.6 kB) Copy SHA256 Checksum SHA256||–||Source||Oct 28, 2016|