diff --git a/pyproject.toml b/pyproject.toml index 4d2dc14..9f9c948 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ filterwarnings = [ "error", # Fail the tests if there are any warnings. "ignore:^find_module\\(\\) is deprecated and slated for removal in Python 3.12; use find_spec\\(\\) instead$:DeprecationWarning:importlib", "ignore:^FileFinder.find_loader\\(\\) is deprecated and slated for removal in Python 3.12; use find_spec\\(\\) instead$:DeprecationWarning:importlib", + "ignore:^pkg_resources is deprecated as an API:DeprecationWarning:pkg_resources", "ignore:^pkg_resources is deprecated as an API:DeprecationWarning:pyramid", "ignore:^Deprecated call to .pkg_resources\\.declare_namespace\\('.*'\\).\\.:DeprecationWarning:pkg_resources", ] diff --git a/tests/pytest_plugins/factory_boy.py b/tests/pytest_plugins/factory_boy.py new file mode 100644 index 0000000..cad2ba6 --- /dev/null +++ b/tests/pytest_plugins/factory_boy.py @@ -0,0 +1,10 @@ +import factory.random +import pytest + + +@pytest.fixture(scope="session", autouse=True) +def factory_boy_random_seed(): + # Set factory_boy's random seed so that it produces the same random values + # in each run of the tests. + # See: https://factoryboy.readthedocs.io/en/latest/index.html#reproducible-random-values + factory.random.reseed_random("hypothesis/h-vialib") diff --git a/tox.ini b/tox.ini index 8f6de61..e7492c4 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ setenv = dev: SENTRY_ENVIRONMENT = {env:SENTRY_ENVIRONMENT:dev} dev: NEW_RELIC_APP_NAME = {env:NEW_RELIC_APP_NAME:h-vialib} dev: NEW_RELIC_ENVIRONMENT = {env:NEW_RELIC_ENVIRONMENT:dev} + tests,functests: PYTEST_PLUGINS = tests.pytest_plugins.factory_boy passenv = HOME PYTEST_ADDOPTS @@ -36,6 +37,7 @@ deps = lint,tests,coverage: coverage[toml] lint,tests,functests: pytest lint,tests,functests: factory-boy + lint,tests,functests: pytest-factoryboy lint,tests,functests: h-matchers lint,template: cookiecutter lint,tests,functests: freezegun @@ -52,7 +54,7 @@ commands = lint: pydocstyle src tests bin lint: pycodestyle src tests bin tests: coverage run -m pytest --failed-first --new-first --no-header --quiet {posargs:tests/unit/} - functests: pytest --failed-first --new-first --no-header --quiet {posargs:tests/functional/} + functests: python -m pytest --failed-first --new-first --no-header --quiet {posargs:tests/functional/} coverage: -coverage combine coverage: coverage report template: python3 bin/make_template {posargs}