Skip to content

Commit

Permalink
Do not save data with _pytest.outcomes.Exit
Browse files Browse the repository at this point in the history
This was changed in pytest (will be in 4.1).

`Exit` is derived from `SystemExit` and not `KeyboardInterrupt` anymore.

Ref pytest-dev/pytest#4292
  • Loading branch information
blueyed committed Dec 14, 2018
1 parent 5ce358a commit ac41aed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
24 changes: 24 additions & 0 deletions test/test_testmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,30 @@ def test_2():
# interrupted run shouldn't save .testmondata
assert 1800000000 == os.path.getmtime(datafilename)

def test_outcomes_exit(self, testdir):
testdir.makepyfile(test_a="""
def test_1():
1
def test_2():
2
""")
testdir.runpytest("--testmon")

tf = testdir.makepyfile(test_a="""
def test_1():
import pytest
pytest.exit("pytest_exit")
def test_2():
3
""")
os.utime(datafilename, (1800000000, 1800000000))
tf.setmtime(1800000000)
testdir.runpytest("--testmon", )
# interrupted run shouldn't save .testmondata
assert 1800000000 == os.path.getmtime(datafilename)

def test_nonfunc_class(self, testdir, monkeypatch):
""""
"""
Expand Down
3 changes: 2 additions & 1 deletion testmon/pytest_testmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def pytest_runtest_protocol(self, item, nextitem):
else:
self.testmon.start()
result = yield
if result.excinfo and issubclass(result.excinfo[0], KeyboardInterrupt):
if result.excinfo and issubclass(result.excinfo[0], (
KeyboardInterrupt, SystemExit)):
self.testmon.stop()
else:
self.testmon.stop_and_save(self.testmon_data, item.config.rootdir.strpath, item.nodeid,
Expand Down

0 comments on commit ac41aed

Please sign in to comment.