Skip to content

Commit 3cb5d00

Browse files
authored
Merge pull request #64 from amateja/master
Run away from getfuncargvalue deprecation.
2 parents a392889 + 67e0200 commit 3cb5d00

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

pytest_flask/plugin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
client, config, accept_json, accept_jsonp, accept_any, accept_mimetype,
1616
client_class, live_server, request_ctx
1717
)
18+
from .pytest_compat import getfixturevalue
1819

1920

2021
class JSONResponse(object):
@@ -58,7 +59,7 @@ def test_json(client):
5859
if 'app' not in request.fixturenames:
5960
return
6061

61-
app = request.getfuncargvalue('app')
62+
app = getfixturevalue(request, 'app')
6263
monkeypatch.setattr(app, 'response_class',
6364
_make_test_response_class(app.response_class))
6465

@@ -75,14 +76,14 @@ def test_app(app, client):
7576
if 'app' not in request.fixturenames:
7677
return
7778

78-
app = request.getfuncargvalue('app')
79+
app = getfixturevalue(request, 'app')
7980

8081
# Get application bound to the live server if ``live_server`` fixture
8182
# is applyed. Live server application has an explicit ``SERVER_NAME``,
8283
# so ``url_for`` function generates a complete URL for endpoint which
8384
# includes application port as well.
8485
if 'live_server' in request.fixturenames:
85-
app = request.getfuncargvalue('live_server').app
86+
app = getfixturevalue(request, 'live_server').app
8687

8788
ctx = app.test_request_context()
8889
ctx.push()
@@ -106,7 +107,7 @@ def test_something(app):
106107
if 'app' not in request.fixturenames:
107108
return
108109

109-
app = request.getfuncargvalue('app')
110+
app = getfixturevalue(request, 'app')
110111
options = request.keywords.get('options')
111112
if options is not None:
112113
for key, value in options.kwargs.items():

pytest_flask/pytest_compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def getfixturevalue(request, value):
2+
if hasattr(request, 'getfixturevalue'):
3+
return request.getfixturevalue(value)
4+
5+
return request.getfuncargvalue(value)

requirements/test.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ mock
22
pylint
33
pytest-cov
44
pytest-pep8
5-
pytest-xdist

tox.ini

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
[tox]
22
envlist =
3-
py{36,35,34,33,27,26}-pytest{30,29,28,27,26}
4-
pypy-pytest{30,29,28,27,26}
3+
py{36,35}-pytest{31,30,29,28,27}
4+
py{34,33,27,26}-pytest{31,30,29,28,27,26}
5+
pypy-pytest{31,30,29,28,27,26}
56

67

78
[pytest]
@@ -16,10 +17,14 @@ usedevelop = True
1617
deps =
1718
-rrequirements/main.txt
1819
-rrequirements/test.txt
19-
pytest23: pytest>=2.3,<2.4
20-
pytest24: pytest>=2.4,<2.5
21-
pytest25: pytest>=2.5,<2.6
2220
pytest26: pytest>=2.6,<2.7
21+
pytest27: pytest>=2.7,<2.8
22+
pytest28: pytest>=2.8,<2.9
23+
pytest29: pytest>=2.9,<3.0
24+
pytest30: pytest>=3.0,<3.1
25+
pytest31: pytest>=3.1,<3.2
26+
pytest26: pytest-xdist<1.16.0
27+
pytest{31,30,29,28,27}: pytest-xdist
2328

2429
passenv = HOME LANG LC_ALL
2530

@@ -46,9 +51,9 @@ whitelist_externals =
4651

4752

4853
[tox:travis]
49-
2.6 = py26-pytest{30,29,28,27,26}
50-
2.7 = py27-pytest{30,29,28,27,26}
51-
3.3 = py33-pytest{30,29,28,27,26}
52-
3.4 = py34-pytest{30,29,28,27,26}
53-
3.5 = py35-pytest{30,29,28,27,26}
54-
3.6 = py36-pytest{30,29,28,27,26}
54+
2.6 = py26-pytest{31,30,29,28,27,26}
55+
2.7 = py27-pytest{31,30,29,28,27,26}
56+
3.3 = py33-pytest{31,30,29,28,27,26}
57+
3.4 = py34-pytest{31,30,29,28,27,26}
58+
3.5 = py35-pytest{31,30,29,28,27}
59+
3.6 = py36-pytest{31,30,29,28,27}

0 commit comments

Comments
 (0)