diff --git a/bench/bench.py b/bench/bench.py index 4e72444e7..31cc7ac13 100644 --- a/bench/bench.py +++ b/bench/bench.py @@ -5,7 +5,7 @@ if __name__ == "__main__": import pytest # NOQA import pstats - script = sys.argv[1:] if len(sys.argv) > 1 else "empty.py" + script = sys.argv[1:] if len(sys.argv) > 1 else ["empty.py"] stats = cProfile.run("pytest.cmdline.main(%r)" % script, "prof") p = pstats.Stats("prof") p.strip_dirs() diff --git a/changelog/4912.trivial.rst b/changelog/4912.trivial.rst index 9c5ca6d8e..9600c833b 100644 --- a/changelog/4912.trivial.rst +++ b/changelog/4912.trivial.rst @@ -1 +1,2 @@ -Remove deprecated Sphinx directive, ``add_description_unit()``. +Remove deprecated Sphinx directive, ``add_description_unit()``, +pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0. diff --git a/doc/en/reference.rst b/doc/en/reference.rst index ca1061a8f..bd89d024d 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -199,16 +199,18 @@ Marks a test function as *expected to fail*. .. py:function:: pytest.mark.xfail(condition=None, *, reason=None, raises=None, run=True, strict=False) :type condition: bool or str - :param condition: ``True/False`` if the condition should be marked as xfail or a :ref:`condition string `. + :param condition: + Condition for marking the test function as xfail (``True/False`` or a + :ref:`condition string `). :keyword str reason: Reason why the test function is marked as xfail. :keyword Exception raises: Exception subclass expected to be raised by the test function; other exceptions will fail the test. :keyword bool run: If the test function should actually be executed. If ``False``, the function will always xfail and will - not be executed (useful a function is segfaulting). + not be executed (useful if a function is segfaulting). :keyword bool strict: * If ``False`` (the default) the function will be shown in the terminal output as ``xfailed`` if it fails and as ``xpass`` if it passes. In both cases this will not cause the test suite to fail as a whole. This - is particularly useful to mark *flaky* tests (tests that random at fail) to be tackled later. + is particularly useful to mark *flaky* tests (tests that fail at random) to be tackled later. * If ``True``, the function will be shown in the terminal output as ``xfailed`` if it fails, but if it unexpectedly passes then it will **fail** the test suite. This is particularly useful to mark functions that are always failing and there should be a clear indication if they unexpectedly start to pass (for example diff --git a/doc/en/requirements.txt b/doc/en/requirements.txt index 320ee8dcd..be22b7db8 100644 --- a/doc/en/requirements.txt +++ b/doc/en/requirements.txt @@ -1,4 +1,4 @@ pygments-pytest>=1.1.0 -sphinx>=1.8.2,<2.0 +sphinx>=1.8.2,<2.1 sphinxcontrib-trio -sphinx-removed-in>=0.1.3 +sphinx-removed-in>=0.2.0 diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py index 7bd319b1a..ece690006 100644 --- a/src/_pytest/capture.py +++ b/src/_pytest/capture.py @@ -539,7 +539,10 @@ class FDCaptureBinary(object): self.tmpfile_fd = tmpfile.fileno() def __repr__(self): - return "" % (self.targetfd, self.targetfd_save) + return "" % ( + self.targetfd, + getattr(self, "targetfd_save", None), + ) def start(self): """ Start capturing on targetfd using memorized tmpfile. """ diff --git a/testing/test_capture.py b/testing/test_capture.py index 91cf8d8cf..5ed806fa4 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -1231,20 +1231,27 @@ class TestStdCaptureFDinvalidFD(object): """ import os from _pytest import capture + def StdCaptureFD(out=True, err=True, in_=True): return capture.MultiCapture(out, err, in_, - Capture=capture.FDCapture) + Capture=capture.FDCapture) + def test_stdout(): os.close(1) cap = StdCaptureFD(out=True, err=False, in_=False) + assert repr(cap.out) == "" cap.stop_capturing() + def test_stderr(): os.close(2) cap = StdCaptureFD(out=False, err=True, in_=False) + assert repr(cap.err) == "" cap.stop_capturing() + def test_stdin(): os.close(0) cap = StdCaptureFD(out=False, err=False, in_=True) + assert repr(cap.in_) == "" cap.stop_capturing() """ )