def pytest_runtest_logreport(self, report): path, test_id = self._test_id(report.nodeid) if path in self.isolated: self.isolated[path].update( [i for i in _get_current_dependencies() if i in self.contracts] ) idx = self.node_map[path].index(test_id) results = self.results[path] if report.when == "call": results[idx] = convert_outcome(report.outcome) if hasattr(report, "wasxfail"): results[idx] = "x" if report.skipped else "X" elif report.failed: results[idx] = "E" if report.when != "teardown" or idx < len(self.node_map[path]) - 1: return isolated = False if path in self.isolated: isolated = sorted(self.isolated[path]) txhash = coverage._get_active_txlist() coverage._clear_active_txlist() if not CONFIG.argv["coverage"] and (path in self.tests and self.tests[path]["coverage"]): txhash = self.tests[path]["txhash"] self.tests[path] = { "sha1": self._get_hash(path), "isolated": isolated, "coverage": CONFIG.argv["coverage"] or (path in self.tests and self.tests[path]["coverage"]), "txhash": txhash, "results": "".join(self.results[path]), }
def module_completed(self, path): path = self._path(path) isolated = False if path in self.isolated: isolated = [ i for i in _get_current_dependencies() if i in self.contracts ] txhash = coverage._get_active_txlist() coverage._clear_active_txlist() if not ARGV["coverage"] and (path in self.tests and self.tests[path]["coverage"]): txhash = self.tests[path]["txhash"] self.tests[path] = { "sha1": self._get_hash(path), "isolated": isolated, "coverage": ARGV["coverage"] or (path in self.tests and self.tests[path]["coverage"]), "txhash": txhash, "results": "".join(self.results), }
def pytest_runtest_logreport(self, report): """ Process a test setup/call/teardown report relating to the respective phase of executing a test. * Updates isolation data for the given test module * Stores the outcome of the test in `self.results` * During teardown of the final test in a given module, resets coverage data and records results for that module in `self.tests` Arguments --------- report : _pytest.reports.BaseReport Report object for the current test. """ path, test_id = self._test_id(report.nodeid) idx = self.node_map[path].index(test_id) # update module isolation data if path in self.isolated: self.isolated[path].update([ i for i in _get_current_dependencies() if i in self.contracts ]) # save results for this test results = self.results[path] if not self.skip.get(report.nodeid): if report.when == "call": results[idx] = convert_outcome(report.outcome) if hasattr(report, "wasxfail"): results[idx] = "x" if report.skipped else "X" elif report.failed: results[idx] = "E" if report.when != "teardown" or idx < len(self.node_map[path]) - 1: return # record and reset coverage data txhash = coverage._get_active_txlist() coverage._clear_active_txlist() if not CONFIG.argv["coverage"] and (path in self.tests and self.tests[path]["coverage"]): # if coverage is not active but we already have coverage data from # a previous run, retain the previous data txhash = self.tests[path]["txhash"] # save module test results isolated = False if path in self.isolated: isolated = sorted(self.isolated[path]) is_cov = CONFIG.argv["coverage"] or (path in self.tests and self.tests[path]["coverage"]) self.tests[path] = { "sha1": self._get_hash(path), "isolated": isolated, "coverage": is_cov, "txhash": txhash, "results": "".join(self.results[path]), }