Reset random.seed()
before every test case
This commit is contained in:
parent
4c0c7887e5
commit
3d9f990c68
3 changed files with 22 additions and 1 deletions
|
@ -230,11 +230,14 @@ TEST_DEPENDENCIES = (
|
|||
"packaging",
|
||||
"pytest",
|
||||
"pytest-cov",
|
||||
"pytest-randomly",
|
||||
"semver",
|
||||
'typing-extensions; python_version < "3.11"', # to support Python 3.9 & 3.10
|
||||
"xdoctest",
|
||||
)
|
||||
|
||||
TEST_RANDOM_SEED = "--randomly-seed=42"
|
||||
|
||||
|
||||
@nox.session(python=SUPPORTED_PYTHONS)
|
||||
def test(session: nox.Session) -> None:
|
||||
|
@ -250,6 +253,7 @@ def test(session: nox.Session) -> None:
|
|||
args = posargs or (
|
||||
"--cov",
|
||||
"--no-cov-on-fail",
|
||||
TEST_RANDOM_SEED,
|
||||
TESTS_LOCATION,
|
||||
)
|
||||
|
||||
|
@ -294,6 +298,7 @@ def test_coverage_run(session: nox.Session) -> None:
|
|||
"run",
|
||||
"-m",
|
||||
"pytest",
|
||||
TEST_RANDOM_SEED,
|
||||
TESTS_LOCATION,
|
||||
)
|
||||
|
||||
|
|
17
poetry.lock
generated
17
poetry.lock
generated
|
@ -1219,6 +1219,21 @@ pytest = ">=4.6"
|
|||
[package.extras]
|
||||
testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-randomly"
|
||||
version = "3.15.0"
|
||||
description = "Pytest plugin to randomly order tests and control random.seed."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pytest_randomly-3.15.0-py3-none-any.whl", hash = "sha256:0516f4344b29f4e9cdae8bce31c4aeebf59d0b9ef05927c33354ff3859eeeca6"},
|
||||
{file = "pytest_randomly-3.15.0.tar.gz", hash = "sha256:b908529648667ba5e54723088edd6f82252f540cc340d748d1fa985539687047"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
importlib-metadata = {version = ">=3.6.0", markers = "python_version < \"3.10\""}
|
||||
pytest = "*"
|
||||
|
||||
[[package]]
|
||||
name = "pyyaml"
|
||||
version = "6.0.2"
|
||||
|
@ -1699,4 +1714,4 @@ type = ["pytest-mypy"]
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.9"
|
||||
content-hash = "d5e420036c32cb6043efd303ae45663287a7bda00036c94fd9497f9346fde701"
|
||||
content-hash = "31a7b1ad8dd8949814d1f397022e400cd37643c6f5e9e438054de472091bcd69"
|
||||
|
|
|
@ -77,6 +77,7 @@ coverage = "^7.6"
|
|||
packaging = "^24.1" # to test the version identifier
|
||||
pytest = "^8.3"
|
||||
pytest-cov = "^5.0"
|
||||
pytest-randomly = "^3.15"
|
||||
semver = "^3.0" # to test the version identifier
|
||||
tomli = [ { python = "<3.11", version = "^2.0" } ]
|
||||
xdoctest = { extras = ["colors"], version = "^1.2" }
|
||||
|
|
Loading…
Reference in a new issue