[Pytest-commit] commit/pytest: 2 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Dec 10 14:59:15 CET 2013
2 new commits in pytest:
https://bitbucket.org/hpk42/pytest/commits/9ba85a8955da/
Changeset: 9ba85a8955da
Branch: override-fixture-via-parametrization
User: bubenkoff
Date: 2013-12-10 14:27:29
Summary: Paratrization overrides existing fixtures.
Affected #: 2 files
diff -r 4c16e1c06b5d0bcad11840fba22bc7604c1f1fbd -r 9ba85a8955daaa5d0b040fb2143c196bc90d3e54 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -368,7 +368,6 @@
arg2fixturedefs = metafunc._arg2fixturedefs
for param_index, callspec in enumerate(metafunc._calls):
for argname, argvalue in callspec.funcargs.items():
- assert argname not in arg2fixturedefs
arg2params.setdefault(argname, []).append(argvalue)
if argname not in arg2scope:
scopenum = callspec._arg2scopenum.get(argname, scopenum_function)
@@ -387,7 +386,6 @@
# to make sure we only ever create an according fixturedef on
# a per-scope basis. We thus store and cache the fixturedef on the
# node related to the scope.
- assert argname not in arg2fixturedefs, (argname, arg2fixturedefs)
scope = arg2scope[argname]
node = None
if scope != "function":
diff -r 4c16e1c06b5d0bcad11840fba22bc7604c1f1fbd -r 9ba85a8955daaa5d0b040fb2143c196bc90d3e54 testing/python/collect.py
--- a/testing/python/collect.py
+++ b/testing/python/collect.py
@@ -372,6 +372,24 @@
rec.assertoutcome(passed=2)
+ def test_parametrize_overrides_fixture(self, testdir):
+ """Test parametrization when parameter overrides existing fixture with same name."""
+ testdir.makepyfile("""
+ import pytest
+
+ @pytest.fixture
+ def value():
+ return 'value'
+
+ @pytest.mark.parametrize('value',
+ ['overrided'])
+ def test_overrided_via_param(value):
+ assert value == 'overrided'
+ """)
+ rec = testdir.inline_run()
+ rec.assertoutcome(passed=1)
+
+
def test_parametrize_with_mark(selfself, testdir):
items = testdir.getitems("""
import pytest
https://bitbucket.org/hpk42/pytest/commits/6bc51574e761/
Changeset: 6bc51574e761
User: hpk42
Date: 2013-12-10 14:59:10
Summary: Merged in paylogic/pytest/override-fixture-via-parametrization (pull request #92)
Paratrization overrides existing fixtures.
Affected #: 2 files
diff -r 23152b79f1dc6ad64a2e6a73a327b770352ca6f7 -r 6bc51574e761e06bae5975cb51914a679bd4f60e _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -368,7 +368,6 @@
arg2fixturedefs = metafunc._arg2fixturedefs
for param_index, callspec in enumerate(metafunc._calls):
for argname, argvalue in callspec.funcargs.items():
- assert argname not in arg2fixturedefs
arg2params.setdefault(argname, []).append(argvalue)
if argname not in arg2scope:
scopenum = callspec._arg2scopenum.get(argname, scopenum_function)
@@ -387,7 +386,6 @@
# to make sure we only ever create an according fixturedef on
# a per-scope basis. We thus store and cache the fixturedef on the
# node related to the scope.
- assert argname not in arg2fixturedefs, (argname, arg2fixturedefs)
scope = arg2scope[argname]
node = None
if scope != "function":
diff -r 23152b79f1dc6ad64a2e6a73a327b770352ca6f7 -r 6bc51574e761e06bae5975cb51914a679bd4f60e testing/python/collect.py
--- a/testing/python/collect.py
+++ b/testing/python/collect.py
@@ -372,6 +372,24 @@
rec.assertoutcome(passed=2)
+ def test_parametrize_overrides_fixture(self, testdir):
+ """Test parametrization when parameter overrides existing fixture with same name."""
+ testdir.makepyfile("""
+ import pytest
+
+ @pytest.fixture
+ def value():
+ return 'value'
+
+ @pytest.mark.parametrize('value',
+ ['overrided'])
+ def test_overrided_via_param(value):
+ assert value == 'overrided'
+ """)
+ rec = testdir.inline_run()
+ rec.assertoutcome(passed=1)
+
+
def test_parametrize_with_mark(selfself, testdir):
items = testdir.getitems("""
import pytest
Repository URL: https://bitbucket.org/hpk42/pytest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list