[Pytest-commit] commit/pytest: RonnyPfannschmidt: Merged in hpk42/pytest-hpk/issue473 (pull request #152)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Apr 9 06:46:05 CEST 2014
1 new commit in pytest:
https://bitbucket.org/hpk42/pytest/commits/7b32e3807b23/
Changeset: 7b32e3807b23
User: RonnyPfannschmidt
Date: 2014-04-09 06:46:01
Summary: Merged in hpk42/pytest-hpk/issue473 (pull request #152)
fix issue473: work around mock putting an unbound method into a class
Affected #: 3 files
diff -r 81ac392651f55934e99828e279c38990e76a873e -r 7b32e3807b231ba322b86223668d805bdacca464 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
NEXT (2.6)
-----------------------------------
+- fix issue473: work around mock putting an unbound method into a class
+ dict when double-patching.
+
- fix issue498: if a fixture finalizer fails, make sure that
the fixture is still invalidated.
diff -r 81ac392651f55934e99828e279c38990e76a873e -r 7b32e3807b231ba322b86223668d805bdacca464 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -222,6 +222,8 @@
return Class(name, parent=collector)
elif collector.funcnamefilter(name) and hasattr(obj, "__call__") and \
getfixturemarker(obj) is None:
+ # mock seems to store unbound methods (issue473), let's normalize it
+ obj = getattr(obj, "__func__", obj)
if not isfunction(obj):
collector.warn(code="C2", message=
"cannot collect %r because it is not a function."
diff -r 81ac392651f55934e99828e279c38990e76a873e -r 7b32e3807b231ba322b86223668d805bdacca464 testing/python/integration.py
--- a/testing/python/integration.py
+++ b/testing/python/integration.py
@@ -164,6 +164,21 @@
names = [x.nodeid.split("::")[-1] for x in calls]
assert names == ["test_one", "test_two", "test_three"]
+ def test_mock_double_patch_issue473(self, testdir):
+ testdir.makepyfile("""
+ from mock import patch
+ from pytest import mark
+
+ @patch('os.getcwd')
+ @patch('os.path')
+ @mark.slow
+ class TestSimple:
+ def test_simple_thing(self, mock_path, mock_getcwd):
+ pass
+ """)
+ res = testdir.inline_run()
+ res.assertoutcome(passed=1)
+
class TestReRunTests:
def test_rerun(self, testdir):
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