add failing test for #3498

This commit is contained in:
Ronny Pfannschmidt 2018-05-24 07:30:38 +02:00
parent afde9f07f7
commit 74cfdc5feb
1 changed files with 47 additions and 0 deletions

View File

@ -828,3 +828,50 @@ def test_class_method_containing_test_issue1558(testdir):
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)
@pytest.mark.issue(3498)
@pytest.mark.parametrize("base", [
'six.moves.builtins.object',
'unittest.TestCase',
'unittest2.TestCase',
])
def test_usefixtures_marker_on_unittest(base, testdir):
module = base.rsplit('.', 1)[0]
pytest.importorskip(module)
testdir.makepyfile(conftest="""
import pytest
@pytest.fixture(scope='function')
def fixture1(request, monkeypatch):
monkeypatch.setattr(request.instance, 'fixture1', True )
@pytest.fixture(scope='function')
def fixture2(request, monkeypatch):
monkeypatch.setattr(request.instance, 'fixture2', True )
""")
testdir.makepyfile("""
import pytest
import {module}
class Tests({base}):
fixture1 = False
fixture2 = False
@pytest.mark.usefixtures("fixture1")
def test_one(self):
assert self.fixture1
assert not self.fixture2
@pytest.mark.usefixtures("fixture1", "fixture2")
def test_two(self):
assert self.fixture1
assert self.fixture2
""".format(module=module, base=base))
result = testdir.runpytest()
result.assert_outcomes(passed=2)