Injection of fixture doesn't work when decorated with unittest.mock.patch
This is a continuation of #182 --HG-- branch : mock-unittest-252
This commit is contained in:
parent
d98521b0d9
commit
0dd378da30
|
@ -112,6 +112,26 @@ class TestMockDecoration:
|
||||||
reprec = testdir.inline_run()
|
reprec = testdir.inline_run()
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
|
def test_unittest_mock_and_fixture(self, testdir):
|
||||||
|
pytest.importorskip("unittest.mock")
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import os.path
|
||||||
|
import unittest.mock
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def inject_me():
|
||||||
|
pass
|
||||||
|
|
||||||
|
@unittest.mock.patch.object(os.path, "abspath",
|
||||||
|
new=unittest.mock.MagicMock)
|
||||||
|
def test_hello(inject_me):
|
||||||
|
import os
|
||||||
|
os.path.abspath("hello")
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run()
|
||||||
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
def test_mock(self, testdir):
|
def test_mock(self, testdir):
|
||||||
pytest.importorskip("mock", "1.0.1")
|
pytest.importorskip("mock", "1.0.1")
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
|
|
Loading…
Reference in New Issue