Skip to main content

Simple factoryboy random state management

Project description

PyPI version Python versions Status tests pre-commit status Black

pytest plugin to manage random state in factory_boy.

factory_boy uses randomness in order to generate its fuzzed values which makes it hard to reproduce tests which fail due to a fuzzed value. This plugin shows the random state used by factory_boy (and faker) when there are test failurs. And allows to run the tests with a specific random state.


  • Show random state on test failures using cli option --show-state or by setting an environment variable.

  • Set random state through environment variable or with cli option --set-state



You can install “pytest-factoryboy-state” via pip from PyPI:

$ pip install pytest-factoryboy-state


Show the random state of factoryboy on test failure with:

$ pytest --show-state

Or by defining the environment variable SHOW_FACTORYBOY_STATE to True.

Rerun the tests with a given state:

$ pytest --set-state=<factoryboy_state>

You can also set the environment variable FACTORYBOY_STATE to the state and run pytest as usual.


Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.


Distributed under the terms of the MIT license, “pytest-factoryboy-state” is free and open source software


If you encounter any problems, please file an issue along with a detailed description.

This pytest plugin was generated with Cookiecutter along with @hackebrot’s cookiecutter-pytest-plugin template.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-factoryboy-state-1.0.0.tar.gz (13.0 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page