remove "StdCapture*.call" classmethod because pytest does not use it.
--HG-- branch : capsimple1
This commit is contained in:
parent
3cf4e133cc
commit
18e12cbd67
|
@ -409,22 +409,6 @@ class EncodedFile(object):
|
|||
|
||||
|
||||
class Capture(object):
|
||||
def call(cls, func, *args, **kwargs):
|
||||
""" return a (res, out, err) tuple where
|
||||
out and err represent the output/error output
|
||||
during function execution.
|
||||
call the given function with args/kwargs
|
||||
and capture output/error during its execution.
|
||||
"""
|
||||
so = cls()
|
||||
so.startall()
|
||||
try:
|
||||
res = func(*args, **kwargs)
|
||||
finally:
|
||||
out, err = so.reset()
|
||||
return res, out, err
|
||||
call = classmethod(call)
|
||||
|
||||
def reset(self):
|
||||
""" reset sys.stdout/stderr and return captured output as strings. """
|
||||
if hasattr(self, '_reset'):
|
||||
|
|
|
@ -896,17 +896,6 @@ class TestStdCaptureFD(TestStdCapture):
|
|||
assert out == "123"
|
||||
assert err == "abc"
|
||||
|
||||
def test_callcapture(self):
|
||||
def func(x, y):
|
||||
print (x)
|
||||
sys.stderr.write(str(y))
|
||||
return 42
|
||||
|
||||
res, out, err = capture.StdCaptureFD.call(func, 3, y=4)
|
||||
assert res == 42
|
||||
assert out.startswith("3")
|
||||
assert err.startswith("4")
|
||||
|
||||
def test_many(self, capfd):
|
||||
def f():
|
||||
for i in range(10):
|
||||
|
@ -977,26 +966,6 @@ def test_capture_no_sys():
|
|||
capsys.reset()
|
||||
|
||||
|
||||
@needsosdup
|
||||
def test_callcapture_nofd():
|
||||
def func(x, y):
|
||||
oswritebytes(1, "hello")
|
||||
oswritebytes(2, "hello")
|
||||
print (x)
|
||||
sys.stderr.write(str(y))
|
||||
return 42
|
||||
|
||||
capfd = capture.StdCaptureFD(patchsys=False)
|
||||
capfd.startall()
|
||||
try:
|
||||
res, out, err = capture.StdCapture.call(func, 3, y=4)
|
||||
finally:
|
||||
capfd.reset()
|
||||
assert res == 42
|
||||
assert out.startswith("3")
|
||||
assert err.startswith("4")
|
||||
|
||||
|
||||
@needsosdup
|
||||
@pytest.mark.parametrize('use', [True, False])
|
||||
def test_fdcapture_tmpfile_remains_the_same(tmpfile, use):
|
||||
|
|
Loading…
Reference in New Issue