Skip to content

Commit da72e65

Browse files
author
deathaxe
authored
Always start coverage after reloading (#257)
If coverage tracking is started before reloading plugins, all modules which are reloaded (but maybe not tested) are recorded, which creates a wrong result. Thus the option `start_coverage_after_reload` is dropped and its behavior made the default.
1 parent d4ab3fc commit da72e65

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ UnitTesting could be configured by providing the following settings in `unittest
143143
| show_reload_progress | print a detailed list of reloaded modules to console | false |
144144
| coverage | track test case coverage | false |
145145
| coverage_on_worker_thread | (experimental) | false |
146-
| start_coverage_after_reload | self explained, irrelevent if `coverage` or `reload_package_on_testing` are false | false |
147146
| generate_html_report | generate HTML report for coverage | false |
148147
| generate_xml_report | generate XML report for coverage | false |
149148

unittesting/base.py

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"show_reload_progress": False,
2828
# coverage
2929
"coverage": False,
30-
"start_coverage_after_reload": False,
3130
"coverage_on_worker_thread": False, # experimental
3231
"generate_html_report": False,
3332
"generate_xml_report": False,

unittesting/unit.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ def run(self, package=None, **kwargs):
102102
self.run_coverage(package, stream, settings)
103103

104104
def run_coverage(self, package, stream, settings):
105+
if settings["reload_package_on_testing"]:
106+
reload_package(package)
107+
105108
if not coverage or not settings["coverage"]:
106109
if settings["coverage"]:
107110
stream.write("Warning: coverage cannot be loaded.\n\n")
108111

109-
if settings["reload_package_on_testing"]:
110-
reload_package(package, verbose=settings["show_reload_progress"])
111-
112112
self.run_tests(stream, package, settings, [])
113113
return
114114

@@ -136,12 +136,7 @@ def run_coverage(self, package, stream, settings):
136136
data_file=data_file, config_file=config_file, include=include, omit=omit
137137
)
138138

139-
if not settings["start_coverage_after_reload"]:
140-
cov.start()
141-
if settings["reload_package_on_testing"]:
142-
reload_package(package, verbose=settings["show_reload_progress"])
143-
if settings["start_coverage_after_reload"]:
144-
cov.start()
139+
cov.start()
145140

146141
if settings["coverage_on_worker_thread"]:
147142
import threading

0 commit comments

Comments
 (0)