From 2af0a023c90c0d3326e7463dbdcd032ede4bcc17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 15 Mar 2019 10:56:13 +0100 Subject: [PATCH 1/4] Pin sphinx-removed-in to >= 0.2.0 to support Sphinx 2.0 Fixes https://github.com/pytest-dev/pytest/issues/4912 --- changelog/4912.trivial.rst | 3 ++- doc/en/requirements.txt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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/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 From 519157cfcfda1c7b6852612fd9aaa0d9a1d8de3b Mon Sep 17 00:00:00 2001 From: smheidrich Date: Sun, 17 Mar 2019 10:14:40 +0100 Subject: [PATCH 2/4] Minor grammar fixes in pytest.mark.xfail docs --- doc/en/reference.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 From 8c96b65082b469b3bc8f1c6f8618924b002b22df Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 18 Mar 2019 02:27:53 +0100 Subject: [PATCH 3/4] Fix bench/bench.py without args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: > File "…/Vcs/pytest/src/_pytest/config/__init__.py", line 60, in main > config = _prepareconfig(args, plugins) > File "…/Vcs/pytest/src/_pytest/config/__init__.py", line 179, in _prepareconfig > raise TypeError(msg.format(args, type(args))) > TypeError: `args` parameter expected to be a list or tuple of strings, got: 'empty.py' (type: ) --- bench/bench.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() From 98981276a0aac62edb6725e138afc4b5ed4b38ca Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 18 Mar 2019 02:06:52 +0100 Subject: [PATCH 4/4] capture: fix FDCapture.__repr__ without targetfd_save --- src/_pytest/capture.py | 5 ++++- testing/test_capture.py | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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() """ )