-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue1625, rename getfuncargvalue to getfixturevalue #1626
Merged
nicoddemus
merged 1 commit into
pytest-dev:master
from
tomviner:issue1625/rename-getfuncargvalue
Jun 24, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,12 +93,12 @@ def test_conftest_funcargs_only_available_in_subdir(self, testdir): | |
sub1.join("conftest.py").write(_pytest._code.Source(""" | ||
import pytest | ||
def pytest_funcarg__arg1(request): | ||
pytest.raises(Exception, "request.getfuncargvalue('arg2')") | ||
pytest.raises(Exception, "request.getfixturevalue('arg2')") | ||
""")) | ||
sub2.join("conftest.py").write(_pytest._code.Source(""" | ||
import pytest | ||
def pytest_funcarg__arg2(request): | ||
pytest.raises(Exception, "request.getfuncargvalue('arg1')") | ||
pytest.raises(Exception, "request.getfixturevalue('arg1')") | ||
""")) | ||
|
||
sub1.join("test_in_sub1.py").write("def test_1(arg1): pass") | ||
|
@@ -435,21 +435,23 @@ def test_method(self, something): | |
assert len(arg2fixturedefs) == 1 | ||
assert arg2fixturedefs[0].__name__ == "pytest_funcarg__something" | ||
|
||
def test_getfuncargvalue_recursive(self, testdir): | ||
def test_getfixturevalue_recursive(self, testdir): | ||
testdir.makeconftest(""" | ||
def pytest_funcarg__something(request): | ||
return 1 | ||
""") | ||
testdir.makepyfile(""" | ||
def pytest_funcarg__something(request): | ||
return request.getfuncargvalue("something") + 1 | ||
return request.getfixturevalue("something") + 1 | ||
def test_func(something): | ||
assert something == 2 | ||
""") | ||
reprec = testdir.inline_run() | ||
reprec.assertoutcome(passed=1) | ||
|
||
def test_getfuncargvalue(self, testdir): | ||
@pytest.mark.parametrize( | ||
'getfixmethod', ('getfixturevalue', 'getfuncargvalue')) | ||
def test_getfixturevalue(self, testdir, getfixmethod): | ||
item = testdir.getitem(""" | ||
l = [2] | ||
def pytest_funcarg__something(request): return 1 | ||
|
@@ -458,14 +460,15 @@ def pytest_funcarg__other(request): | |
def test_func(something): pass | ||
""") | ||
req = item._request | ||
pytest.raises(FixtureLookupError, req.getfuncargvalue, "notexists") | ||
val = req.getfuncargvalue("something") | ||
fixture_fetcher = getattr(req, getfixmethod) | ||
pytest.raises(FixtureLookupError, fixture_fetcher, "notexists") | ||
val = fixture_fetcher("something") | ||
assert val == 1 | ||
val = req.getfuncargvalue("something") | ||
val = fixture_fetcher("something") | ||
assert val == 1 | ||
val2 = req.getfuncargvalue("other") | ||
val2 = fixture_fetcher("other") | ||
assert val2 == 2 | ||
val2 = req.getfuncargvalue("other") # see about caching | ||
val2 = fixture_fetcher("other") # see about caching | ||
assert val2 == 2 | ||
pytest._fillfuncargs(item) | ||
assert item.funcargs["something"] == 1 | ||
|
@@ -812,10 +815,10 @@ def test_two_different_setups(arg1, arg2): | |
"*1 passed*" | ||
]) | ||
|
||
def test_request_cached_setup_getfuncargvalue(self, testdir): | ||
def test_request_cached_setup_getfixturevalue(self, testdir): | ||
testdir.makepyfile(""" | ||
def pytest_funcarg__arg1(request): | ||
arg1 = request.getfuncargvalue("arg2") | ||
arg1 = request.getfixturevalue("arg2") | ||
return request.cached_setup(lambda: arg1 + 1) | ||
def pytest_funcarg__arg2(request): | ||
return request.cached_setup(lambda: 10) | ||
|
@@ -1118,7 +1121,7 @@ def test_2(arg2): | |
|
||
class TestFixtureManagerParseFactories: | ||
def pytest_funcarg__testdir(self, request): | ||
testdir = request.getfuncargvalue("testdir") | ||
testdir = request.getfixturevalue("testdir") | ||
testdir.makeconftest(""" | ||
def pytest_funcarg__hello(request): | ||
return "conftest" | ||
|
@@ -1804,9 +1807,9 @@ def test_4(arg, created, finalized): | |
reprec.assertoutcome(passed=4) | ||
|
||
@pytest.mark.parametrize("method", [ | ||
'request.getfuncargvalue("arg")', | ||
'request.getfixturevalue("arg")', | ||
'request.cached_setup(lambda: None, scope="function")', | ||
], ids=["getfuncargvalue", "cached_setup"]) | ||
], ids=["getfixturevalue", "cached_setup"]) | ||
def test_scope_mismatch_various(self, testdir, method): | ||
testdir.makeconftest(""" | ||
import pytest | ||
|
@@ -2737,6 +2740,7 @@ def test_1(arg1): | |
*def arg1* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why were these tests removed? |
||
""") | ||
|
||
|
||
class TestParameterizedSubRequest: | ||
def test_call_from_fixture(self, testdir): | ||
testfile = testdir.makepyfile(""" | ||
|
@@ -2748,7 +2752,7 @@ def fix_with_param(request): | |
|
||
@pytest.fixture | ||
def get_named_fixture(request): | ||
return request.getfuncargvalue('fix_with_param') | ||
return request.getfixturevalue('fix_with_param') | ||
|
||
def test_foo(request, get_named_fixture): | ||
pass | ||
|
@@ -2773,7 +2777,7 @@ def fix_with_param(request): | |
return request.param | ||
|
||
def test_foo(request): | ||
request.getfuncargvalue('fix_with_param') | ||
request.getfixturevalue('fix_with_param') | ||
""") | ||
result = testdir.runpytest() | ||
result.stdout.fnmatch_lines(""" | ||
|
@@ -2797,7 +2801,7 @@ def fix_with_param(request): | |
|
||
testfile = testdir.makepyfile(""" | ||
def test_foo(request): | ||
request.getfuncargvalue('fix_with_param') | ||
request.getfixturevalue('fix_with_param') | ||
""") | ||
result = testdir.runpytest() | ||
result.stdout.fnmatch_lines(""" | ||
|
@@ -2827,7 +2831,7 @@ def fix_with_param(request): | |
from fix import fix_with_param | ||
|
||
def test_foo(request): | ||
request.getfuncargvalue('fix_with_param') | ||
request.getfixturevalue('fix_with_param') | ||
""")) | ||
|
||
tests_dir.chdir() | ||
|
@@ -2842,3 +2846,7 @@ def test_foo(request): | |
E*{1}:5 | ||
*1 failed* | ||
""".format(fixfile.strpath, testfile.basename)) | ||
|
||
|
||
def test_getfuncargvalue_is_deprecated(request): | ||
pytest.deprecated_call(request.getfuncargvalue, 'tmpdir') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason the code above passes, but this fails: def test_getfuncargvalue_is_deprecated_with(request):
with pytest.deprecated_call():
request.getfuncargvalue('tmpdir') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"
getfuncargvalue
deprecated" -> is deprecated?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need to add a link for
@RedBeardCode
to the referencesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The linting fails because we added @RedBeardCode to Changelog links in another PR.