rename StdCaptureBase to MultiCapture
This commit is contained in:
parent
95cc114b34
commit
69cbac8fb5
|
@ -81,11 +81,11 @@ class CaptureManager:
|
||||||
|
|
||||||
def _getcapture(self, method):
|
def _getcapture(self, method):
|
||||||
if method == "fd":
|
if method == "fd":
|
||||||
return StdCaptureBase(out=True, err=True, Capture=FDCapture)
|
return MultiCapture(out=True, err=True, Capture=FDCapture)
|
||||||
elif method == "sys":
|
elif method == "sys":
|
||||||
return StdCaptureBase(out=True, err=True, Capture=SysCapture)
|
return MultiCapture(out=True, err=True, Capture=SysCapture)
|
||||||
elif method == "no":
|
elif method == "no":
|
||||||
return StdCaptureBase(out=False, err=False, in_=False)
|
return MultiCapture(out=False, err=False, in_=False)
|
||||||
else:
|
else:
|
||||||
raise ValueError("unknown capturing method: %r" % method)
|
raise ValueError("unknown capturing method: %r" % method)
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ class CaptureFixture:
|
||||||
self.captureclass = captureclass
|
self.captureclass = captureclass
|
||||||
|
|
||||||
def _start(self):
|
def _start(self):
|
||||||
self._capture = StdCaptureBase(out=True, err=True, in_=False,
|
self._capture = MultiCapture(out=True, err=True, in_=False,
|
||||||
Capture=self.captureclass)
|
Capture=self.captureclass)
|
||||||
self._capture.start_capturing()
|
self._capture.start_capturing()
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ class EncodedFile(object):
|
||||||
return getattr(self.buffer, name)
|
return getattr(self.buffer, name)
|
||||||
|
|
||||||
|
|
||||||
class StdCaptureBase(object):
|
class MultiCapture(object):
|
||||||
out = err = in_ = None
|
out = err = in_ = None
|
||||||
|
|
||||||
def __init__(self, out=True, err=True, in_=True, Capture=None):
|
def __init__(self, out=True, err=True, in_=True, Capture=None):
|
||||||
|
|
|
@ -46,10 +46,10 @@ def oswritebytes(fd, obj):
|
||||||
|
|
||||||
|
|
||||||
def StdCaptureFD(out=True, err=True, in_=True):
|
def StdCaptureFD(out=True, err=True, in_=True):
|
||||||
return capture.StdCaptureBase(out, err, in_, Capture=capture.FDCapture)
|
return capture.MultiCapture(out, err, in_, Capture=capture.FDCapture)
|
||||||
|
|
||||||
def StdCapture(out=True, err=True, in_=True):
|
def StdCapture(out=True, err=True, in_=True):
|
||||||
return capture.StdCaptureBase(out, err, in_, Capture=capture.SysCapture)
|
return capture.MultiCapture(out, err, in_, Capture=capture.SysCapture)
|
||||||
|
|
||||||
|
|
||||||
class TestCaptureManager:
|
class TestCaptureManager:
|
||||||
|
@ -918,7 +918,7 @@ class TestStdCaptureFDinvalidFD:
|
||||||
import os
|
import os
|
||||||
from _pytest import capture
|
from _pytest import capture
|
||||||
def StdCaptureFD(out=True, err=True, in_=True):
|
def StdCaptureFD(out=True, err=True, in_=True):
|
||||||
return capture.StdCaptureBase(out, err, in_,
|
return capture.MultiCapture(out, err, in_,
|
||||||
Capture=capture.FDCapture)
|
Capture=capture.FDCapture)
|
||||||
def test_stdout():
|
def test_stdout():
|
||||||
os.close(1)
|
os.close(1)
|
||||||
|
@ -958,6 +958,25 @@ def test_fdcapture_tmpfile_remains_the_same(tmpfile, use):
|
||||||
capfile2 = cap.err.tmpfile
|
capfile2 = cap.err.tmpfile
|
||||||
assert capfile2 == capfile
|
assert capfile2 == capfile
|
||||||
|
|
||||||
|
@needsosdup
|
||||||
|
def test_close_and_capture_again(testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import os
|
||||||
|
def test_close():
|
||||||
|
os.close(1)
|
||||||
|
def test_capture_again():
|
||||||
|
os.write(1, "hello\\n")
|
||||||
|
assert 0
|
||||||
|
""")
|
||||||
|
result = testdir.runpytest()
|
||||||
|
result.stdout.fnmatch_lines("""
|
||||||
|
*test_capture_again*
|
||||||
|
*assert 0*
|
||||||
|
*stdout*
|
||||||
|
*hello*
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('method', ['SysCapture', 'FDCapture'])
|
@pytest.mark.parametrize('method', ['SysCapture', 'FDCapture'])
|
||||||
def test_capturing_and_logging_fundamentals(testdir, method):
|
def test_capturing_and_logging_fundamentals(testdir, method):
|
||||||
|
@ -968,7 +987,7 @@ def test_capturing_and_logging_fundamentals(testdir, method):
|
||||||
import sys, os
|
import sys, os
|
||||||
import py, logging
|
import py, logging
|
||||||
from _pytest import capture
|
from _pytest import capture
|
||||||
cap = capture.StdCaptureBase(out=False, in_=False,
|
cap = capture.MultiCapture(out=False, in_=False,
|
||||||
Capture=capture.%s)
|
Capture=capture.%s)
|
||||||
cap.start_capturing()
|
cap.start_capturing()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue