avoid pyc file issues by parametrizing the test instead of rewriting conftest.py files
This commit is contained in:
parent
7bc7a9b702
commit
3049af618c
|
@ -14,7 +14,8 @@ class TestCaptureManager:
|
||||||
finally:
|
finally:
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
|
||||||
def test_configure_per_fspath(self, testdir):
|
@pytest.mark.parametrize("mode", "no fd sys".split())
|
||||||
|
def test_configure_per_fspath(self, testdir, mode):
|
||||||
config = testdir.parseconfig(testdir.tmpdir)
|
config = testdir.parseconfig(testdir.tmpdir)
|
||||||
capman = CaptureManager()
|
capman = CaptureManager()
|
||||||
hasfd = hasattr(os, 'dup')
|
hasfd = hasattr(os, 'dup')
|
||||||
|
@ -23,13 +24,12 @@ class TestCaptureManager:
|
||||||
else:
|
else:
|
||||||
assert capman._getmethod(config, None) == "sys"
|
assert capman._getmethod(config, None) == "sys"
|
||||||
|
|
||||||
for name in ('no', 'fd', 'sys'):
|
if not hasfd and mode == 'fd':
|
||||||
if not hasfd and name == 'fd':
|
return
|
||||||
continue
|
sub = testdir.tmpdir.mkdir("dir" + mode)
|
||||||
sub = testdir.tmpdir.mkdir("dir" + name)
|
|
||||||
sub.ensure("__init__.py")
|
sub.ensure("__init__.py")
|
||||||
sub.join("conftest.py").write('option_capture = %r' % name)
|
sub.join("conftest.py").write('option_capture = %r' % mode)
|
||||||
assert capman._getmethod(config, sub.join("test_hello.py")) == name
|
assert capman._getmethod(config, sub.join("test_hello.py")) == mode
|
||||||
|
|
||||||
@needsosdup
|
@needsosdup
|
||||||
@pytest.mark.multi(method=['no', 'fd', 'sys'])
|
@pytest.mark.multi(method=['no', 'fd', 'sys'])
|
||||||
|
|
Loading…
Reference in New Issue