Skip to content

WIP: save data with --xfail / -x #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions testmon/pytest_testmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ def pytest_runtest_protocol(self, item, nextitem):
yield

self.testmon.start()
yield
self.testmon.stop_and_save(self.testmon_data, item.config.rootdir.strpath, item.nodeid)
result = yield
# NOTE: pytest-watch also sends KeyboardInterrupt when changes are
# detected. This should still save the collected data up until then.
if result.excinfo and issubclass(result.excinfo[0], KeyboardInterrupt):
self.testmon.stop()
else:
self.testmon.stop_and_save(self.testmon_data, item.config.rootdir.strpath, item.nodeid)

def pytest_runtest_logreport(self, report):
if report.failed and "xfail" not in report.keywords:
Expand Down Expand Up @@ -170,10 +175,12 @@ def pytest_ignore_collect(self, path, config):
def pytest_internalerror(self, excrepr, excinfo):
self.testmon_save = False

def pytest_keyboard_interrupt(self, excinfo):
self.testmon_save = False

def pytest_sessionfinish(self, session):
if self.testmon_save:
self.testmon_data.write_data()
self.testmon.close()

def pytest_terminal_summary(self, terminalreporter, exitstatus=None):
if (not self.testmon_save and
terminalreporter.config.getvalue('verbose')):
terminalreporter.line('testmon: not saving data')
5 changes: 4 additions & 1 deletion testmon/testmon_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ def start(self):
self.cov.erase()
self.cov.start()

def stop_and_save(self, testmon_data, rootdir, nodeid):
def stop(self):
self.cov.stop()

def stop_and_save(self, testmon_data, rootdir, nodeid):
self.stop()
if hasattr(self, 'sub_cov_file'):
self.cov.combine()

Expand Down