Skip to content

Commit f34a591

Browse files
committed
Fix some of the warnings displayed by pytest 3.1.0
pytest 3.1.0 now displays warnings by default and this PR fixes some of them.
1 parent 880e01e commit f34a591

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

tests/test_quickstart.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def test_quickstart_main_choose_individual_pythons_and_pytest(
6363
deps =
6464
pytest
6565
""".lstrip()
66-
result = open('tox.ini').read()
66+
result = read_tox()
6767
assert(result == expected_tox_ini)
6868

6969
def test_quickstart_main_choose_individual_pythons_and_nose_adds_deps(
@@ -105,7 +105,7 @@ def test_quickstart_main_choose_individual_pythons_and_nose_adds_deps(
105105
deps =
106106
nose
107107
""".lstrip()
108-
result = open('tox.ini').read()
108+
result = read_tox()
109109
assert(result == expected_tox_ini)
110110

111111
def test_quickstart_main_choose_individual_pythons_and_trial_adds_deps(
@@ -147,7 +147,7 @@ def test_quickstart_main_choose_individual_pythons_and_trial_adds_deps(
147147
deps =
148148
twisted
149149
""".lstrip()
150-
result = open('tox.ini').read()
150+
result = read_tox()
151151
assert(result == expected_tox_ini)
152152

153153
def test_quickstart_main_choose_individual_pythons_and_pytest_adds_deps(
@@ -188,7 +188,7 @@ def test_quickstart_main_choose_individual_pythons_and_pytest_adds_deps(
188188
deps =
189189
pytest
190190
""".lstrip()
191-
result = open('tox.ini').read()
191+
result = read_tox()
192192
assert(result == expected_tox_ini)
193193

194194
def test_quickstart_main_choose_py27_and_pytest_adds_deps(
@@ -221,7 +221,7 @@ def test_quickstart_main_choose_py27_and_pytest_adds_deps(
221221
deps =
222222
pytest
223223
""".lstrip()
224-
result = open('tox.ini').read()
224+
result = read_tox()
225225
assert(result == expected_tox_ini)
226226

227227
def test_quickstart_main_choose_py27_and_py33_and_pytest_adds_deps(
@@ -254,7 +254,7 @@ def test_quickstart_main_choose_py27_and_py33_and_pytest_adds_deps(
254254
deps =
255255
pytest
256256
""".lstrip()
257-
result = open('tox.ini').read()
257+
result = read_tox()
258258
assert(result == expected_tox_ini)
259259

260260
def test_quickstart_main_choose_all_pythons_and_pytest_adds_deps(
@@ -287,7 +287,7 @@ def test_quickstart_main_choose_all_pythons_and_pytest_adds_deps(
287287
deps =
288288
pytest
289289
""".lstrip()
290-
result = open('tox.ini').read()
290+
result = read_tox()
291291
assert(result == expected_tox_ini)
292292

293293
def test_quickstart_main_choose_individual_pythons_and_defaults(
@@ -329,7 +329,7 @@ def test_quickstart_main_choose_individual_pythons_and_defaults(
329329
deps =
330330
331331
""".lstrip()
332-
result = open('tox.ini').read()
332+
result = read_tox()
333333
assert(result == expected_tox_ini)
334334

335335
def test_quickstart_main_existing_tox_ini(self, monkeypatch):
@@ -376,7 +376,7 @@ def test_quickstart_main_existing_tox_ini(self, monkeypatch):
376376
deps =
377377
378378
""".lstrip()
379-
result = open('tox-generated.ini').read()
379+
result = read_tox('tox-generated.ini')
380380
assert(result == expected_tox_ini)
381381

382382

@@ -408,7 +408,7 @@ def test_pytest(self):
408408
""".lstrip()
409409
d = tox._quickstart.process_input(d)
410410
tox._quickstart.generate(d)
411-
result = open('tox.ini').read()
411+
result = read_tox()
412412
# print(result)
413413
assert(result == expected_tox_ini)
414414

@@ -435,7 +435,7 @@ def test_setup_py_test(self):
435435
""".lstrip()
436436
d = tox._quickstart.process_input(d)
437437
tox._quickstart.generate(d)
438-
result = open('tox.ini').read()
438+
result = read_tox()
439439
# print(result)
440440
assert(result == expected_tox_ini)
441441

@@ -461,7 +461,7 @@ def test_trial(self):
461461
""".lstrip()
462462
d = tox._quickstart.process_input(d)
463463
tox._quickstart.generate(d)
464-
result = open('tox.ini').read()
464+
result = read_tox()
465465
# print(result)
466466
assert(result == expected_tox_ini)
467467

@@ -492,6 +492,11 @@ def test_nosetests(self):
492492
""".lstrip()
493493
d = tox._quickstart.process_input(d)
494494
tox._quickstart.generate(d)
495-
result = open('tox.ini').read()
495+
result = read_tox()
496496
# print(result)
497497
assert(result == expected_tox_ini)
498+
499+
500+
def read_tox(fname='tox.ini'):
501+
with open(fname) as f:
502+
return f.read()

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ commands=echo {posargs}
77
[testenv]
88
commands= py.test --timeout=180 {posargs:tests}
99

10-
deps=pytest>=2.3.5
10+
deps=pytest>=3.0.0
1111
pytest-timeout
1212

1313
[testenv:py26-bare]

tox/_pytestplugin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def mocksession(request):
142142
class MockSession(Session):
143143
def __init__(self):
144144
self._clearmocks()
145-
self.config = request.getfuncargvalue("newconfig")([], "")
145+
self.config = request.getfixturevalue("newconfig")([], "")
146146
self.resultlog = ResultLog()
147147
self._actions = []
148148

@@ -168,8 +168,8 @@ def popen(self, args, cwd, shell=None,
168168

169169
@pytest.fixture
170170
def newmocksession(request):
171-
mocksession = request.getfuncargvalue("mocksession")
172-
newconfig = request.getfuncargvalue("newconfig")
171+
mocksession = request.getfixturevalue("mocksession")
172+
newconfig = request.getfixturevalue("newconfig")
173173

174174
def newmocksession(args, source, plugins=()):
175175
mocksession.config = newconfig(args, source, plugins=plugins)
@@ -179,7 +179,7 @@ def newmocksession(args, source, plugins=()):
179179

180180
class Cmd:
181181
def __init__(self, request):
182-
self.tmpdir = request.getfuncargvalue("tmpdir")
182+
self.tmpdir = request.getfixturevalue("tmpdir")
183183
self.request = request
184184
current = py.path.local()
185185
self.request.addfinalizer(current.chdir)

0 commit comments

Comments
 (0)