Skip to content

Commit e5bfb9b

Browse files
author
Alex Remedios
authored
read .coveragerc (#12)
1 parent a4f7c7a commit e5bfb9b

3 files changed

Lines changed: 15 additions & 7 deletions

File tree

python-cli/src/deeptest/pytest_plugin.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import shutil
22
import sys
3+
from pathlib import Path
34
from typing import Any, List, cast
45

56
from _pytest.config import Config
67
from _pytest.config.argparsing import Parser
8+
from coverage import Coverage
79
from pytest import ExitCode, hookimpl
810

9-
out_path = ".deeptest/junit.xml"
11+
JUNIT_DEST = ".deeptest/junit.xml"
12+
COV_DEST = ".deeptest/.coverage"
1013

1114

1215
def is_enabled(config: Config) -> bool:
@@ -28,12 +31,18 @@ def pytest_load_initial_conftests(
2831

2932
def pytest_configure(config: Config):
3033
if is_enabled(config) and config.option.xmlpath is None:
31-
config.option.xmlpath = out_path
34+
config.option.xmlpath = JUNIT_DEST
3235

3336

3437
def pytest_terminal_summary(
3538
terminalreporter: Any, exitstatus: ExitCode, config: Config
3639
):
37-
if is_enabled(config) and config.option.xmlpath != out_path:
38-
print(f"Copying {config.option.xmlpath} to {out_path}")
39-
shutil.copy(config.option.xmlpath, out_path)
40+
if is_enabled(config):
41+
Path(".deeptest").mkdir(exist_ok=True)
42+
43+
if config.option.xmlpath != JUNIT_DEST:
44+
shutil.copy(config.option.xmlpath, JUNIT_DEST)
45+
46+
cc = Coverage(config_file=config.option.cov_config)
47+
if cc.config.data_file != COV_DEST:
48+
shutil.copy(cc.config.data_file, COV_DEST)

python-cli/tests/resources/.coveragerc

Lines changed: 0 additions & 2 deletions
This file was deleted.

python-cli/tests/test_pytest_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def test_when_no_xml_then_output_correctly(testdir: Testdir, fake_repo: object):
2828

2929
assert hook_recorder.ret == ExitCode.TESTS_FAILED
3030
assert Path(".deeptest/junit.xml").exists()
31+
assert Path(".deeptest/.coverage").exists()
3132

3233

3334
def test_when_other_xml_then_output_correctly(testdir: Testdir, fake_repo: object):

0 commit comments

Comments
 (0)