tests: Improve handling of tests skipped by default

- Create the 'heavy' mark for tests that take long to run.
- Skip the tests marked as 'heavy' by default.
- Enable functional and heavy tests by setting the environment variable
  EXTENDED_TESTING=1.
- Update HACKING.md accordingly.

Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
[sunil: Minor indentation]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Fioddor Superconcentrado authored and Sunil Mohan Adapa committed 2021-10-10 19:22:13 -07:00
1 parent 4b708214e4
commit cb539cf1e8
3 files changed
+49 -14

No files matched your search

+22 -11
View File
@@ -31,18 +31,29 @@ def pytest_addoption(parser):
def pytest_collection_modifyitems(config, items):
"""Filter out functional tests unless --include-functional is passed."""
if config.getoption('--include-functional'):
# Option provided on command line, no filtering
return
"""Filter out specificly marked tests unless explicitly requested.
skip_functional = pytest.mark.skip(
reason='--include-functional not provided')
for item in items:
if 'functional' in item.keywords or (item.parent.fspath.basename
and item.parent.fspath.basename
== 'test_functional.py'):
item.add_marker(skip_functional)
The EXTENDED_TESTING environment variable is borrowed from the Lancaster
consensus met by the Pearl community. See
https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md
"""
def skip(item, reason):
item.add_marker(pytest.mark.skip(reason=reason))
extended = 'EXTENDED_TESTING' in os.environ
if not (extended or config.getoption('--include-functional')):
for item in items:
if 'functional' in item.keywords or (
item.parent.fspath.basename
and item.parent.fspath.basename == 'test_functional.py'):
skip(item, '--include-functional not provided')
if not extended:
for item in items:
if 'heavy' in item.keywords:
skip(item, ('Takes too much time. '
'Set EXTENDED_TESTING=1 to force run'))
@pytest.fixture(name='load_cfg')