Skip to main content

Simple factoryboy random state management

Project description

PyPI version Python versions Status tests pre-commit pre-commit.ci 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.

Features

  • 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

Requirements

Installation

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

$ pip install pytest-factoryboy-state

Usage

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.

Contributing

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.

License

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

Issues

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 Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page