[Pytest-commit] commit/pytest: hpk42: allow to use pytest.fixture decorator on old-style pytest_funcarg__NAME definitions.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Dec 4 07:16:51 CET 2013


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/aa1f0505a315/
Changeset:   aa1f0505a315
User:        hpk42
Date:        2013-12-04 07:16:34
Summary:     allow to use pytest.fixture decorator on old-style pytest_funcarg__NAME definitions.
Affected #:  3 files

diff -r ef64b4405d0caf4ba5bb390f591889b99be574a1 -r aa1f0505a3156b9feca43cd67c5afc95622b9ac5 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -93,6 +93,9 @@
 
 - fix verbose reporting for @mock'd test functions
 
+- allow @pytest.fixture marked pytest_funcarg__foo functions
+  so that pylint errors can be avoided.
+
 Changes between 2.4.1 and 2.4.2
 -----------------------------------
 

diff -r ef64b4405d0caf4ba5bb390f591889b99be574a1 -r aa1f0505a3156b9feca43cd67c5afc95622b9ac5 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -1660,8 +1660,9 @@
                 # magic globals  with __getattr__ might have got us a wrong
                 # fixture attribute
                 continue
-            else:
-                assert not name.startswith(self._argprefix)
+            elif name.startswith(self._argprefix):
+                # let's allso fixture-marked pytest_funcarg__ prefixed functions
+                name = name[len(self._argprefix):]
             fixturedef = FixtureDef(self, nodeid, name, obj,
                                     marker.scope, marker.params,
                                     yieldctx=marker.yieldctx,

diff -r ef64b4405d0caf4ba5bb390f591889b99be574a1 -r aa1f0505a3156b9feca43cd67c5afc95622b9ac5 testing/python/integration.py
--- a/testing/python/integration.py
+++ b/testing/python/integration.py
@@ -195,3 +195,16 @@
 def test_pytestconfig_is_session_scoped():
     from _pytest.python import pytestconfig
     assert pytestconfig._pytestfixturefunction.scope == "session"
+
+def test_funcarg_prefix_and_marker(testdir):
+    testdir.makepyfile("""
+        import pytest
+        @pytest.fixture
+        def pytest_funcarg__foo():
+            return 1
+
+        def test_hello(foo):
+            assert foo == 1
+    """)
+    reprec = testdir.inline_run()
+    reprec.assertoutcome(passed=1)

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