Commits

Ronny Pfannschmidt committed 2e54141

test unittest-allmodules

Comments (0)

Files changed (3)

monkeypatch-descriptors

-# HG changeset patch
-# Parent d46b4480e6de290d9b965618981f9f186030380f
-fix issue 156 - monkypaych undo broken for staticmethod
-
-diff --git a/_pytest/monkeypatch.py b/_pytest/monkeypatch.py
---- a/_pytest/monkeypatch.py
-+++ b/_pytest/monkeypatch.py
-@@ -39,6 +39,10 @@ class monkeypatch:
-         oldval = getattr(obj, name, notset)
-         if raising and oldval is notset:
-             raise AttributeError("%r has no attribute %r" %(obj, name))
-+
-+        vars = getattr(obj, '__dict__', notset)
-+        if vars is not notset:
-+            oldval = vars.get(name, notset)
-         self._setattr.insert(0, (obj, name, oldval))
-         setattr(obj, name, value)
- 
-diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py
---- a/testing/test_monkeypatch.py
-+++ b/testing/test_monkeypatch.py
-@@ -206,3 +206,38 @@ def test_issue185_time_breaks(testdir):
-     result.stdout.fnmatch_lines("""
-         *1 passed*
-     """)
-+
-+
-+
-+class SampleNew(object):
-+    @staticmethod
-+    def hello():
-+        return True
-+
-+
-+class SampleNewInherit(SampleNew):
-+    pass
-+
-+
-+class SampleOld:
-+    #oldstyle on python2
-+    @staticmethod
-+    def hello():
-+        return True
-+
-+class SampleOldInherit(SampleOld):
-+    pass
-+
-+
-+@pytest.mark.parametrize('Sample', [
-+    SampleNew, SampleNewInherit,
-+    SampleOld, SampleOldInherit,
-+], ids=['new', 'new-inherit', 'old', 'old-inherit'])
-+def test_issue156_undo_staticmethod(Sample):
-+    monkeypatch = MonkeyPatch()
-+
-+    monkeypatch.setattr(Sample, 'hello', None)
-+    assert Sample.hello is None
-+
-+    monkeypatch.undo()
-+    assert Sample.hello()
-monkeypatch-descriptors
+unittest-allmodules
 issue187 #+issue187
 parametrize
 handle-usageerror
+# HG changeset patch
+# Parent 34f5117685c06f1d7bd3b18672e7bfe8e5bd3fef
+diff --git a/testing/test_unittest.py b/testing/test_unittest.py
+--- a/testing/test_unittest.py
++++ b/testing/test_unittest.py
+@@ -564,3 +564,30 @@ def test_unittest_setup_interaction(test
+     """)
+     result = testdir.runpytest()
+     result.stdout.fnmatch_lines("*3 passed*")
++
++
++def test_unittest_allmodules(testdir):
++    testdir.makepyfile(example_module="""
++        import unittest
++        class TestFun(unittest.TestCase):
++            def test_findme(self):
++                pass
++
++        def test_dontfindme():
++            assert 0
++        """)
++
++    result = testdir.runpytest()
++    result.stdout.fnmatch_lines([
++        "collected 0 items",
++        "==  in .* seconds ="
++    ])
++    
++    testdir.makeini("""
++        [pytest]
++        unittest_allmodules = yes
++        """)
++    result = testdir.runpytest()
++    result.stdout.fnmatch_lines([
++        "1 passed"
++    ])