From 75a6e659c95f6ca466f06ba6dbfcf90a04513eef Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 15 Apr 2019 00:22:48 +0200 Subject: [PATCH] WIP: skip pytest_ignore_collect with -k/-m Ref: https://github.com/tarpas/pytest-testmon/issues/135 --- testmon/pytest_testmon.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testmon/pytest_testmon.py b/testmon/pytest_testmon.py index 28fb48d..c32575f 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])