Skip to content

Commit 0975e06

Browse files
committed
Merge pull request #8 from klrmn/issue_8
add environmental testing via tox
2 parents 90d5219 + cf23f1d commit 0975e06

5 files changed

Lines changed: 276 additions & 10 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.DS_Store
22
*.pyc
3-
*egg*
3+
*egg*
4+
build/*
5+
.tox*

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The output should look something like this if run with '--reruns=2 -r fsxXR'
4848
XPASS test_report_on_with_reruns.py::test_xpass this will pass
4949
====== 1 failed, 1 passed, 1 xfailed, 1 xpassed, 1 rerun in 0.04 seconds =======
5050

51+
Note: The output will only show RERUN if the test failed and then subsequently passed. Tests that fail on all the reruns will be marked as FAILED.
5152

5253
Compatibility:
5354
==============
@@ -61,3 +62,14 @@ This plugin is also not compatible with the core --pdb flag.
6162
Continuous Integration
6263
----------------------
6364
[![Build Status](https://secure.travis-ci.org/klrmn/pytest-rerunfailures.png?branch=master)](http://travis-ci.org/klrmn/pytest-rerunfailures)
65+
66+
Running the tests:
67+
=================
68+
to test in your current environment:
69+
$ python setup.py install
70+
$ py.test .
71+
or for all of the supported environments:
72+
$ (sudo) pip install tox
73+
$ tox
74+
75+
There are 3 tests which are conditional on the presence of pytest-xdist.

tests/__init__.py

Whitespace-only changes.

tests/test_functionality.py

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ def test_report_on_with_reruns(self, testdir):
234234
assert self._substring_in_output('1 rerun', result.outlines)
235235
assert self._substring_in_output('RERUN test_report_on_with_reruns.py::test_flaky_test', result.outlines)
236236

237-
238237
def test_report_on_without_reruns(self, testdir):
239238
test_file = self.variety_of_tests(testdir)
240239

@@ -257,24 +256,71 @@ def test_report_on_without_reruns(self, testdir):
257256
assert not self._substring_in_output('RERUN test_report_on_without_reruns.py::test_flaky_test', result.errlines)
258257
assert not self._substring_in_output('1 rerun', result.outlines)
259258

260-
def test_report_with_xdist_dash_n(self, testdir):
261-
'''This test is identical to test_flakey_test_report_normal except it
259+
# pytest-xdist -n compatibility tests
260+
261+
def test_report_off_with_reruns_with_xdist(self, testdir):
262+
'''This test is identical to test_report_off_with_reruns except it
263+
also uses xdist's -n flag.
264+
'''
265+
# precondition: xdist installed
266+
self._pytest_xdist_installed(testdir)
267+
268+
test_file = self.variety_of_tests(testdir)
269+
270+
result = testdir.runpytest('--reruns=2', '-n 1')
271+
272+
assert self._substring_in_output('.FxXR', result.outlines)
273+
274+
assert self._substring_in_output('1 passed', result.outlines)
275+
276+
assert self._substring_in_output('1 failed', result.outlines)
277+
assert not self._substring_in_output('FAIL test_report_off_with_reruns_with_xdist.py::test_fake_fail', result.outlines)
278+
279+
assert self._substring_in_output('1 xpassed', result.outlines)
280+
assert not self._substring_in_output('XPASS test_report_off_with_reruns_with_xdist.py::test_xpass', result.outlines)
281+
282+
assert self._substring_in_output('1 xfailed', result.outlines)
283+
assert not self._substring_in_output('XFAIL test_report_off_with_reruns_with_xdist.py::test_xfail', result.outlines)
284+
285+
assert not self._substring_in_output('RERUN test_report_off_with_reruns_with_xdist.py::test_flaky_test', result.outlines)
286+
assert self._substring_in_output('1 rerun', result.outlines)
287+
288+
def test_report_on_with_reruns_with_xdist(self, testdir):
289+
'''This test is identical to test_report_on_with_reruns except it
262290
also uses xdist's -n flag.
263291
'''
264292
# precondition: xdist installed
293+
self._pytest_xdist_installed(testdir)
294+
295+
test_file = self.variety_of_tests(testdir)
296+
297+
result = testdir.runpytest('--reruns=2', '-r fsxXR', '-n 1')
298+
299+
assert self._substring_in_output('.FxXR', result.outlines)
300+
301+
assert self._substring_in_output(' 1 passed', result.outlines)
302+
303+
assert self._substring_in_output('1 failed', result.outlines)
304+
assert self._substring_in_output('FAIL test_report_on_with_reruns_with_xdist.py::test_fake_fail', result.outlines)
305+
306+
assert self._substring_in_output('1 xpassed', result.outlines)
307+
assert self._substring_in_output('XPASS test_report_on_with_reruns_with_xdist.py::test_xpass', result.outlines)
308+
309+
assert self._substring_in_output('1 xfailed', result.outlines)
310+
assert self._substring_in_output('XFAIL test_report_on_with_reruns_with_xdist.py::test_xfail', result.outlines)
311+
312+
assert self._substring_in_output('1 rerun', result.outlines)
313+
assert self._substring_in_output('RERUN test_report_on_with_reruns_with_xdist.py::test_flaky_test', result.outlines)
314+
315+
316+
def _pytest_xdist_installed(self, testdir):
265317
try:
266318
result = testdir.runpytest('--version')
267319
result.stderr.fnmatch_lines(['*pytest-xdist*'])
268320
except Exception:
269321
import pytest
270322
pytest.skip("this test requires pytest-xdist")
271323

272-
test_file = testdir.makepyfile(self.flakey_test)
273-
274-
result = testdir.runpytest('--reruns=2', '-n 1', '-r fsxXR')
275-
assert self._substring_in_output('RERUN test_report_with_xdist_dash_n.py::test_flaky_test', result.outlines)
276-
assert self._substring_in_output('1 rerun', result.outlines)
277-
278324
def _substring_in_output(self, substring, output_lines):
279325
print '-' * 30
280326
found = False

tox.ini

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
[tox]
2+
envlist =
3+
py26-pt223-x, py26-pt223,
4+
py26-pt224-x, py26-pt224,
5+
py26-pt23-x, py26-pt23,
6+
py26-pt231-x, py26-pt231,
7+
py26-pt232-x, py26-pt232,
8+
py26-pt233-x, py26-pt233,
9+
py26-pt234-x, py26-pt231,
10+
py26-ptlatest-x, py26-ptlatest,
11+
py27-pt223-x, py27-pt223,
12+
py27-pt224-x, py27-pt224,
13+
py27-pt23-x, py27-pt23,
14+
py27-pt231-x, py27-pt231,
15+
py27-pt232-x, py27-pt232,
16+
py27-pt233-x, py27-pt233,
17+
py27-pt234-x, py27-pt234,
18+
py27-ptlatest-x, py27-ptlatest,
19+
20+
[testenv]
21+
recreate=True
22+
sitepackages=False
23+
commands =
24+
{envbindir}/py.test . {posargs}
25+
26+
# ENVIRONMENT MATRIX
27+
# python versions 2.6, 2.7
28+
# py.test versions 2.2.3, 2.2.4, 2.3, 2.3.1, 2.3.2, 2.3.4 - current
29+
# pytest-xdist installed / not installed
30+
31+
[testenv:py26-pt223-x]
32+
basepython = python2.6
33+
deps =
34+
pytest==2.2.3
35+
pytest-xdist
36+
37+
[testenv:py26-pt223]
38+
basepython = python2.6
39+
deps =
40+
pytest==2.2.3
41+
42+
[testenv:py26-pt224-x]
43+
basepython = python2.6
44+
deps =
45+
pytest==2.2.4
46+
pytest-xdist
47+
48+
[testenv:py26-pt224]
49+
basepython = python2.6
50+
deps =
51+
pytest==2.2.4
52+
53+
[testenv:py26-pt23-x]
54+
basepython = python2.6
55+
deps =
56+
pytest==2.3
57+
pytest-xdist
58+
59+
[testenv:py26-pt23]
60+
basepython = python2.6
61+
deps =
62+
pytest==2.3
63+
64+
[testenv:py26-pt231-x]
65+
basepython = python2.6
66+
deps =
67+
pytest==2.3.1
68+
pytest-xdist
69+
70+
[testenv:py26-pt231]
71+
basepython = python2.6
72+
deps =
73+
pytest==2.3.1
74+
75+
[testenv:py26-pt232-x]
76+
basepython = python2.6
77+
deps =
78+
pytest==2.3.2
79+
pytest-xdist
80+
81+
[testenv:py26-pt232]
82+
basepython = python2.6
83+
deps =
84+
pytest==2.3.2
85+
86+
[testenv:py26-pt233-x]
87+
basepython = python2.6
88+
deps =
89+
pytest==2.3.3
90+
pytest-xdist
91+
92+
[testenv:py26-pt233]
93+
basepython = python2.6
94+
deps =
95+
pytest==2.3.3
96+
97+
[testenv:py26-pt234-x]
98+
basepython = python2.6
99+
deps =
100+
pytest==2.3.4
101+
pytest-xdist
102+
103+
[testenv:py26-pt234]
104+
basepython = python2.6
105+
deps =
106+
pytest==2.3.4
107+
108+
[testenv:py26-ptlatest-x]
109+
basepython = python2.6
110+
deps =
111+
pytest
112+
pytest-xdist
113+
114+
[testenv:py26-ptlatest]
115+
basepython = python2.6
116+
deps =
117+
pytest
118+
119+
120+
[testenv:py27-pt223-x]
121+
basepython = python2.7
122+
deps =
123+
pytest==2.2.3
124+
pytest-xdist
125+
126+
[testenv:py27-pt223]
127+
basepython = python2.7
128+
deps =
129+
pytest==2.2.3
130+
131+
[testenv:py27-pt224-x]
132+
basepython = python2.7
133+
deps =
134+
pytest==2.2.4
135+
pytest-xdist
136+
137+
[testenv:py27-pt224]
138+
basepython = python2.7
139+
deps =
140+
pytest==2.2.4
141+
142+
[testenv:py27-pt23-x]
143+
basepython = python2.7
144+
deps =
145+
pytest==2.3
146+
pytest-xdist
147+
148+
[testenv:py27-pt23]
149+
basepython = python2.7
150+
deps =
151+
pytest==2.3
152+
153+
[testenv:py27-pt231-x]
154+
basepython = python2.7
155+
deps =
156+
pytest==2.3.1
157+
pytest-xdist
158+
159+
[testenv:py27-pt231]
160+
basepython = python2.7
161+
deps =
162+
pytest==2.3.1
163+
164+
[testenv:py27-pt232-x]
165+
basepython = python2.7
166+
deps =
167+
pytest==2.3.2
168+
pytest-xdist
169+
170+
[testenv:py27-pt232]
171+
basepython = python2.7
172+
deps =
173+
pytest==2.3.2
174+
175+
[testenv:py27-pt233-x]
176+
basepython = python2.7
177+
deps =
178+
pytest==2.3.3
179+
pytest-xdist
180+
181+
[testenv:py27-pt233]
182+
basepython = python2.7
183+
deps =
184+
pytest==2.3.3
185+
186+
[testenv:py27-pt234-x]
187+
basepython = python2.7
188+
deps =
189+
pytest==2.3.4
190+
pytest-xdist
191+
192+
[testenv:py27-pt234]
193+
basepython = python2.7
194+
deps =
195+
pytest==2.3.4
196+
197+
[testenv:py27-ptlatest-x]
198+
basepython = python2.7
199+
deps =
200+
pytest
201+
pytest-xdist
202+
203+
[testenv:py27-ptlatest]
204+
basepython = python2.7
205+
deps =
206+
pytest

0 commit comments

Comments
 (0)