Skip to content

Commit a4f7c7a

Browse files
author
Alex Remedios
authored
Merge pull request #11 from treebeardtech:disable-on-collect
disable on collect
2 parents 2786afd + caa49da commit a4f7c7a

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

python-cli/src/deeptest/pytest_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def is_enabled(config: Config) -> bool:
1717
def pytest_load_initial_conftests(
1818
early_config: Config, parser: Parser, args: List[str]
1919
):
20-
if sys.gettrace():
20+
if sys.gettrace() or "--co" in args or "--collect-only" in args:
2121
early_config.known_args_namespace.cov_source = None
2222
early_config.option.no_cov = True
2323

python-cli/tests/test_pytest_plugin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
@pytest.fixture
1919
def fake_repo(testdir: Testdir):
2020
copy_tree(RESOURCES.as_posix(), ".")
21+
shutil.rmtree(".deeptest", ignore_errors=True)
22+
return testdir
2123

2224

2325
def test_when_no_xml_then_output_correctly(testdir: Testdir, fake_repo: object):
@@ -46,3 +48,11 @@ def test_when_trace_present_then_disables_cov(testdir: Testdir, fake_repo: objec
4648

4749
assert hook_recorder.ret == ExitCode.TESTS_FAILED
4850
assert not Path(".deeptest/junit.xml").exists()
51+
52+
53+
def test_when_collect_only_then_no_output(fake_repo: Testdir):
54+
assert not Path(".deeptest/junit.xml").exists()
55+
hook_recorder = fake_repo.inline_run("--co")
56+
57+
assert hook_recorder.ret == ExitCode.OK
58+
assert not Path(".deeptest/junit.xml").exists()

0 commit comments

Comments
 (0)