@@ -942,14 +942,10 @@ def task_provision():
942942 )
943943
944944
945- def _pytest (setup_py , pycov_args , pytest_args ):
945+ def _pytest (setup_py , pytest_args ):
946946 return CmdAction (
947947 [
948948 * P .PYM ,
949- "coverage" ,
950- "run" ,
951- * pycov_args ,
952- "-m" ,
953949 "pytest" ,
954950 * P .PYTEST_ARGS ,
955951 * pytest_args ,
@@ -963,30 +959,6 @@ def _pytest(setup_py, pycov_args, pytest_args):
963959 )
964960
965961
966- def _pycov_combine (setup_py ):
967- return CmdAction (
968- [* P .PYM , "coverage" , "combine" ],
969- shell = False ,
970- cwd = str (setup_py .parent ),
971- )
972-
973-
974- def _pycov_report (setup_py ):
975- return CmdAction (
976- [* P .PYM , "coverage" , "report" , "--skip-covered" , "--show-missing" ],
977- shell = False ,
978- cwd = str (setup_py .parent ),
979- )
980-
981-
982- def _pycov_html (setup_py , * pycov_html_args ):
983- return CmdAction (
984- [* P .PYM , "coverage" , "html" , * pycov_html_args ],
985- shell = False ,
986- cwd = str (setup_py .parent ),
987- )
988-
989-
990962def task_test ():
991963 """Run tests."""
992964 if not P .TESTING_IN_CI :
@@ -1006,24 +978,39 @@ def task_test():
1006978 P .SCRIPTS / "integrity.py" ,
1007979 ],
1008980 "actions" : [
1009- ["python" , "-m" , "pytest" , "--pyargs" , "scripts.integrity" , "-vv" ],
981+ [
982+ * P .PYM ,
983+ "pytest" ,
984+ "--pyargs" ,
985+ "scripts.integrity" ,
986+ "-vv" ,
987+ * ("-o" , f"""cache_dir={ P .CACHE / ".pytest.integrity" } """ ),
988+ ],
1010989 ],
1011990 },
1012991 P .OK_INTEGRITY ,
1013992 )
1014993
1015994 for pkg , setup in P .PY_SETUP .items ():
1016- html = P .BUILD / f"pytest/{ pkg } /test.html"
1017- htmlcov = P .BUILD / f"pytest/{ pkg } /htmlcov"
995+ report_dir = P .REPORTS / "pytest" / pkg
996+ html = report_dir / "pytest.html"
997+ cov_index = report_dir / "htmlcov" / "index.html"
998+ cache_dir = P .CACHE / f".pytest.{ pkg } "
1018999 pytest_args = [
10191000 "-vv" ,
10201001 "--tb=long" ,
1002+ * ("-o" , f"cache_dir={ cache_dir } " ),
1003+ # subs
1004+ "--script-launch-mode=subprocess" ,
1005+ # report
10211006 f"--html={ html } " ,
10221007 "--self-contained-html" ,
1023- "--script-launch-mode=subprocess" ,
1008+ # cov
1009+ "--cov-context=test" ,
1010+ f"""--cov={ pkg .replace ("-" , "_" )} """ ,
1011+ f"--cov-report=html:{ cov_index .parent } " ,
1012+ "--cov-branch" ,
10241013 ]
1025- pycov_args = []
1026- pycov_html_args = [f"--directory={ htmlcov .parent } " ]
10271014
10281015 if pkg == P .IPD .name :
10291016 pytest_args += ["-n" , "auto" ]
@@ -1041,12 +1028,9 @@ def task_test():
10411028 ],
10421029 "actions" : [
10431030 (P .delete_some , [html ]),
1044- _pytest (setup , pycov_args , pytest_args ),
1045- _pycov_combine (setup ),
1046- _pycov_html (setup , * pycov_html_args ),
1047- _pycov_report (setup ),
1031+ _pytest (setup , pytest_args ),
10481032 ],
1049- "targets" : [html ],
1033+ "targets" : [html , cov_index ],
10501034 },
10511035 P .OK_PYTEST [pkg ],
10521036 )
0 commit comments