Bug
The faker_seed autouse fixture in 4.0.x crashes when the plugin is disabled via -p no:randomly.
Version: 4.0.1 (also affects 4.0.0)
Error
TypeError: can only concatenate str (not "int") to str
At src/pytest_randomly/__init__.py:269:
@fixture(autouse=True)
def faker_seed(pytestconfig: Config, request: SubRequest) -> int:
result: int = pytestconfig.getoption("randomly_seed") + _crc32(
request.node.nodeid
)
return result
Root cause
When the plugin is disabled via -p no:randomly, pytest_configure never runs, so config.option.randomly_seed is never resolved from its default value "default" (a string, via seed_type()) to an int (via make_seed()).
The faker_seed fixture is registered at module level (guarded by have_faker, not by plugin state), so it still runs even when the plugin is disabled. It then attempts "default" + _crc32(...), which is a str + int operation.
Reproduction
pip install pytest-randomly==4.0.1 faker factory-boy
pytest -p no:randomly tests/
Every test fails at fixture setup with the TypeError.
Expected behavior
When the plugin is disabled, the faker_seed fixture should either:
- Not be registered, or
- Handle the case where the seed hasn't been resolved to an
int
Worked in 3.x
In 3.x there was no per-test CRC32 arithmetic on the seed, so the string default was never used in an addition operation.
Bug
The
faker_seedautouse fixture in 4.0.x crashes when the plugin is disabled via-p no:randomly.Version: 4.0.1 (also affects 4.0.0)
Error
At
src/pytest_randomly/__init__.py:269:Root cause
When the plugin is disabled via
-p no:randomly,pytest_configurenever runs, soconfig.option.randomly_seedis never resolved from its default value"default"(a string, viaseed_type()) to anint(viamake_seed()).The
faker_seedfixture is registered at module level (guarded byhave_faker, not by plugin state), so it still runs even when the plugin is disabled. It then attempts"default" + _crc32(...), which is astr + intoperation.Reproduction
Every test fails at fixture setup with the TypeError.
Expected behavior
When the plugin is disabled, the
faker_seedfixture should either:intWorked in 3.x
In 3.x there was no per-test CRC32 arithmetic on the seed, so the string default was never used in an addition operation.