11import shutil
22import sys
3+ from pathlib import Path
34from typing import Any , List , cast
45
56from _pytest .config import Config
67from _pytest .config .argparsing import Parser
8+ from coverage import Coverage
79from pytest import ExitCode , hookimpl
810
9- out_path = ".deeptest/junit.xml"
11+ JUNIT_DEST = ".deeptest/junit.xml"
12+ COV_DEST = ".deeptest/.coverage"
1013
1114
1215def is_enabled (config : Config ) -> bool :
@@ -28,12 +31,18 @@ def pytest_load_initial_conftests(
2831
2932def 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
3437def 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 )
0 commit comments