Merge pull request #4953 from blueyed/merge-master-into-features

Merge master into features
This commit is contained in:
Daniel Hahler 2019-03-19 04:13:31 +01:00 committed by GitHub
commit 77c5191ad7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 9 deletions

View File

@ -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()

View File

@ -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.

View File

@ -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 <string conditions>`.
:param condition:
Condition for marking the test function as xfail (``True/False`` or a
:ref:`condition string <string conditions>`).
: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

View File

@ -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

View File

@ -539,7 +539,10 @@ class FDCaptureBinary(object):
self.tmpfile_fd = tmpfile.fileno()
def __repr__(self):
return "<FDCapture %s oldfd=%s>" % (self.targetfd, self.targetfd_save)
return "<FDCapture %s oldfd=%s>" % (
self.targetfd,
getattr(self, "targetfd_save", None),
)
def start(self):
""" Start capturing on targetfd using memorized tmpfile. """

View File

@ -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) == "<FDCapture 1 oldfd=None>"
cap.stop_capturing()
def test_stderr():
os.close(2)
cap = StdCaptureFD(out=False, err=True, in_=False)
assert repr(cap.err) == "<FDCapture 2 oldfd=None>"
cap.stop_capturing()
def test_stdin():
os.close(0)
cap = StdCaptureFD(out=False, err=False, in_=True)
assert repr(cap.in_) == "<FDCapture 0 oldfd=None>"
cap.stop_capturing()
"""
)