From 0aefa226660bcbbadd3af74e52d50bd025f6e838 Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Tue, 15 Dec 2020 11:35:05 +0100 Subject: [PATCH] Integrate pytest-randomly into the test suite As a lot of the integration tests populate the database with test data, it is deemed safer to run the tests in random order to uncover potential dependencies between distinct test cases. Because of how the `db_session` fixture is designed, this should already be taken care of. --- noxfile.py | 2 ++ poetry.lock | 17 ++++++++++++++++- pyproject.toml | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 3c9d3e0..b516587 100644 --- a/noxfile.py +++ b/noxfile.py @@ -226,6 +226,7 @@ def test(session): 'pytest', 'pytest-cov', 'pytest-env', + 'pytest-randomly', 'xdoctest[optional]', ) @@ -240,6 +241,7 @@ def test(session): '--cov-branch', '--cov-fail-under=100', '--cov-report=term-missing:skip-covered', + '--randomly-seed=4287', '-k', 'not e2e', PYTEST_LOCATION, diff --git a/poetry.lock b/poetry.lock index 58c6815..805e302 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1335,6 +1335,17 @@ python-versions = "*" [package.dependencies] pytest = ">=2.6.0" +[[package]] +name = "pytest-randomly" +version = "3.5.0" +description = "Pytest plugin to randomly order tests and control random.seed." +category = "dev" +optional = false +python-versions = ">=3.5" + +[package.dependencies] +pytest = "*" + [[package]] name = "python-dateutil" version = "2.8.1" @@ -1806,7 +1817,7 @@ research = ["jupyterlab", "nb_black", "numpy", "pandas", "pytz"] [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "5f49faba0f11ddf2c4439fe0aad8113a68cbd504b2f68e57dfbec38db3cbe474" +content-hash = "28c08518fa365282d2b06ea2b78784906c69114f05da597ba5df4bcc64fe4aaa" [metadata.files] alabaster = [ @@ -2463,6 +2474,10 @@ pytest-cov = [ pytest-env = [ {file = "pytest-env-0.6.2.tar.gz", hash = "sha256:7e94956aef7f2764f3c147d216ce066bf6c42948bb9e293169b1b1c880a580c2"}, ] +pytest-randomly = [ + {file = "pytest-randomly-3.5.0.tar.gz", hash = "sha256:440cec143fd9b0adeb072006c71e0294402a2bc2ccd08079c2341087ba4cf2d1"}, + {file = "pytest_randomly-3.5.0-py3-none-any.whl", hash = "sha256:9db10d160237f3f8ee60cef72e4cb9ea88d2893c9dd5c8aa334b060cdeb67c3a"}, +] python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, {file = "python_dateutil-2.8.1-py2.py3-none-any.whl", hash = "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"}, diff --git a/pyproject.toml b/pyproject.toml index 2656f96..6d0808d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,6 +75,7 @@ packaging = "^20.4" # used to test the packaged version pytest = "^6.0.1" pytest-cov = "^2.10.0" pytest-env = "^0.6.2" +pytest-randomly = "^3.5.0" xdoctest = { version="^0.13.0", extras=["optional"] } # Documentation