Skip to content

Commit aa4d3ef

Browse files
blueyedtarpas
authored andcommitted
Do not save data with _pytest.outcomes.Exit (#119)
* Do not save data with _pytest.outcomes.Exit This was changed in pytest (will be in 4.1). `Exit` is derived from `SystemExit` and not `KeyboardInterrupt` anymore. Ref pytest-dev/pytest#4292 * tests: use py36-pytest41-xdist
1 parent 5ce358a commit aa4d3ef

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ matrix:
2424
python: 3.6
2525
- env: TOXENV=py36-pytestfeatures
2626
python: 3.6
27-
- env: TOXENV=py36-pytest32-xdist
27+
- env: TOXENV=py36-pytest41-xdist
2828
python: 3.6
2929

3030
install:

test/test_testmon.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,30 @@ def test_2():
301301
# interrupted run shouldn't save .testmondata
302302
assert 1800000000 == os.path.getmtime(datafilename)
303303

304+
def test_outcomes_exit(self, testdir):
305+
testdir.makepyfile(test_a="""
306+
def test_1():
307+
1
308+
309+
def test_2():
310+
2
311+
""")
312+
testdir.runpytest("--testmon")
313+
314+
tf = testdir.makepyfile(test_a="""
315+
def test_1():
316+
import pytest
317+
pytest.exit("pytest_exit")
318+
319+
def test_2():
320+
3
321+
""")
322+
os.utime(datafilename, (1800000000, 1800000000))
323+
tf.setmtime(1800000000)
324+
testdir.runpytest("--testmon", )
325+
# interrupted run shouldn't save .testmondata
326+
assert 1800000000 == os.path.getmtime(datafilename)
327+
304328
def test_nonfunc_class(self, testdir, monkeypatch):
305329
""""
306330
"""
@@ -788,14 +812,14 @@ class TestXdist(object):
788812

789813
def test_xdist_4(self, testdir):
790814
pytest.importorskip("xdist")
791-
testdir.makepyfile(test_a="""\
815+
testdir.makepyfile(test_a="""
792816
import pytest
793817
@pytest.mark.parametrize("a", [
794818
("test0", ),
795819
("test1", ),
796820
("test2", ),
797821
("test3", )
798-
])
822+
])
799823
def test_1(a):
800824
print(a)
801825
""")

testmon/pytest_testmon.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ def pytest_runtest_protocol(self, item, nextitem):
215215
else:
216216
self.testmon.start()
217217
result = yield
218-
if result.excinfo and issubclass(result.excinfo[0], KeyboardInterrupt):
218+
if result.excinfo and issubclass(result.excinfo[0], (
219+
KeyboardInterrupt, SystemExit)):
219220
self.testmon.stop()
220221
else:
221222
self.testmon.stop_and_save(self.testmon_data, item.config.rootdir.strpath, item.nodeid,

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = pytest{31,32,33,master}-py{27,34,35,36},py36-pytest32-xdist,pytestfeatures-py36
2+
envlist = pytest{31,32,33,master}-py{27,34,35,36},py36-pytest41-xdist,pytestfeatures-py36
33

44
[testenv]
55
passenv = PYTHONPATH
@@ -11,6 +11,7 @@ deps =
1111
pytest31: pytest>=3.1,<3.2
1212
pytest32: pytest>=3.2,<3.3
1313
pytest33: pytest>=3.3,<3.4
14+
pytest41: pytest>=4.1,<4.2
1415
# master is current stable version with bugfixes.
1516
pytestmaster: git+https://github.com/pytest-dev/pytest.git@master#egg=pytest
1617
# features is the next non-bugfix version.

0 commit comments

Comments
 (0)