mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Disallow use of script fixture in unit tests
This commit is contained in:
parent
1a46eeda90
commit
3662f5e0df
1
news/10721.feature.rst
Normal file
1
news/10721.feature.rst
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Disallow use of script fixture in unit tests.
|
|
@ -127,6 +127,14 @@ def pytest_collection_modifyitems(config: Config, items: List[pytest.Item]) -> N
|
||||||
item.add_marker(pytest.mark.integration)
|
item.add_marker(pytest.mark.integration)
|
||||||
elif module_root_dir.startswith("unit"):
|
elif module_root_dir.startswith("unit"):
|
||||||
item.add_marker(pytest.mark.unit)
|
item.add_marker(pytest.mark.unit)
|
||||||
|
|
||||||
|
# We don't want to allow using the script resource if this is a
|
||||||
|
# unit test, as unit tests should not need all that heavy lifting
|
||||||
|
if set(getattr(item, "funcargnames", [])) & {"script"}:
|
||||||
|
raise RuntimeError(
|
||||||
|
"Cannot use the ``script`` funcarg in a unit test: "
|
||||||
|
"(filename = {}, item = {})".format(module_path, item)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(f"Unknown test type (filename = {module_path})")
|
raise RuntimeError(f"Unknown test type (filename = {module_path})")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue