Dan Willemsen | adad21e | 2022-03-25 17:22:05 -0700 | [diff] [blame] | 1 | import sys |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | |
Nan Zhang | 8539a2a | 2018-05-15 14:00:05 -0700 | [diff] [blame] | 6 | pytest_plugins = 'setuptools.tests.fixtures' |
| 7 | |
| 8 | |
| 9 | def pytest_addoption(parser): |
| 10 | parser.addoption( |
| 11 | "--package_name", action="append", default=[], |
| 12 | help="list of package_name to pass to test functions", |
| 13 | ) |
Dan Willemsen | adad21e | 2022-03-25 17:22:05 -0700 | [diff] [blame] | 14 | parser.addoption( |
| 15 | "--integration", action="store_true", default=False, |
| 16 | help="run integration tests (only)" |
| 17 | ) |
| 18 | |
| 19 | |
| 20 | def pytest_configure(config): |
| 21 | config.addinivalue_line("markers", "integration: integration tests") |
| 22 | config.addinivalue_line("markers", "uses_network: tests may try to download files") |
| 23 | |
| 24 | |
| 25 | collect_ignore = [ |
| 26 | 'tests/manual_test.py', |
| 27 | 'setuptools/tests/mod_with_constant.py', |
| 28 | 'setuptools/_distutils', |
| 29 | '_distutils_hack', |
| 30 | 'setuptools/extern', |
| 31 | 'pkg_resources/extern', |
| 32 | 'pkg_resources/tests/data', |
| 33 | 'setuptools/_vendor', |
| 34 | 'pkg_resources/_vendor', |
| 35 | ] |
| 36 | |
| 37 | |
| 38 | if sys.version_info < (3, 6): |
| 39 | collect_ignore.append('docs/conf.py') # uses f-strings |
| 40 | collect_ignore.append('pavement.py') |
| 41 | |
| 42 | |
| 43 | @pytest.fixture(autouse=True) |
| 44 | def _skip_integration(request): |
| 45 | running_integration_tests = request.config.getoption("--integration") |
| 46 | is_integration_test = request.node.get_closest_marker("integration") |
| 47 | if running_integration_tests and not is_integration_test: |
| 48 | pytest.skip("running integration tests only") |
| 49 | if not running_integration_tests and is_integration_test: |
| 50 | pytest.skip("skipping integration tests") |