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
2 changed files with 9 additions and 0 deletions
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)
|
||||
elif module_root_dir.startswith("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:
|
||||
raise RuntimeError(f"Unknown test type (filename = {module_path})")
|
||||
|
||||
|
|
Loading…
Reference in a new issue