diff --git a/testmon/pytest_testmon.py b/testmon/pytest_testmon.py index a0d4b3b..9a5a0de 100644 --- a/testmon/pytest_testmon.py +++ b/testmon/pytest_testmon.py @@ -150,6 +150,10 @@ def __init__(self, config, testmon_data): self.f_to_ignore = self.testmon_data.stable_files if self.config.getoption('tlf'): self.f_to_ignore -= self.testmon_data.f_last_failed + self.has_possibly_filtering_args = any( + x for x in config._origargs + if x in ("-k", "-m") + ) def test_should_run(self, nodeid): if self.config.getoption('tlf'): @@ -180,6 +184,8 @@ def pytest_report_header(self, config): return active_message + "." def pytest_ignore_collect(self, path, config): + if self.has_possibly_filtering_args: + return strpath = os.path.relpath(path.strpath, config.rootdir.strpath) if strpath in (self.f_to_ignore): self.collection_ignored.update(self.testmon_data.f_tests[strpath])