diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2018-05-24 07:30:38 +0200 |
---|---|---|
committer | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2018-05-24 07:30:38 +0200 |
commit | 74cfdc5feb9b07ff538b6c85d864437aadeb314e (patch) | |
tree | bc10755c78fc74ae657986be3f3f8ac336b27e39 /testing/test_unittest.py | |
parent | afde9f07f7303511dec3b74850f0e10b1579393b (diff) | |
download | pytest-74cfdc5feb9b07ff538b6c85d864437aadeb314e.tar.gz |
add failing test for #3498
Diffstat (limited to 'testing/test_unittest.py')
-rw-r--r-- | testing/test_unittest.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/test_unittest.py b/testing/test_unittest.py index e19773587..685ca1b7a 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -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) |