Merge pull request #4129 from nicoddemus/merge-master-into-features

Merge master into features (prepare for 3.9)
This commit is contained in:
Bruno Oliveira 2018-10-13 12:05:54 -03:00 committed by GitHub
commit 24c83d725a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 47 additions and 51 deletions

View File

@ -25,8 +25,6 @@ env:
- TOXENV=py36-numpy - TOXENV=py36-numpy
- TOXENV=py36-pluggymaster PYTEST_NO_COVERAGE=1 - TOXENV=py36-pluggymaster PYTEST_NO_COVERAGE=1
- TOXENV=py27-nobyte - TOXENV=py27-nobyte
- TOXENV=doctesting
- TOXENV=docs PYTEST_NO_COVERAGE=1
jobs: jobs:
include: include:
@ -61,7 +59,7 @@ jobs:
env: TOXENV=py27 env: TOXENV=py27
- env: TOXENV=py34 - env: TOXENV=py34
- env: TOXENV=py36 - env: TOXENV=py36
- env: TOXENV=linting PYTEST_NO_COVERAGE=1 - env: TOXENV=linting,docs,doctesting PYTEST_NO_COVERAGE=1
- stage: deploy - stage: deploy
python: '3.6' python: '3.6'

View File

@ -1,6 +1,6 @@
environment: environment:
matrix: matrix:
- TOXENV: "linting" - TOXENV: "linting,docs,doctesting"
PYTEST_NO_COVERAGE: "1" PYTEST_NO_COVERAGE: "1"
- TOXENV: "py27" - TOXENV: "py27"
- TOXENV: "py34" - TOXENV: "py34"
@ -20,11 +20,8 @@ environment:
- TOXENV: "py36-pluggymaster" - TOXENV: "py36-pluggymaster"
PYTEST_NO_COVERAGE: "1" PYTEST_NO_COVERAGE: "1"
- TOXENV: "py27-nobyte" - TOXENV: "py27-nobyte"
- TOXENV: "doctesting"
- TOXENV: "py36-freeze" - TOXENV: "py36-freeze"
PYTEST_NO_COVERAGE: "1" PYTEST_NO_COVERAGE: "1"
- TOXENV: "docs"
PYTEST_NO_COVERAGE: "1"
install: install:
- echo Installed Pythons - echo Installed Pythons

1
changelog/3713.doc.rst Normal file
View File

@ -0,0 +1 @@
Update usefixtures documentation to clarify that it can't be used with fixture functions.

View File

@ -0,0 +1 @@
Fixed formatting of string literals in internal tests.

View File

@ -245,9 +245,9 @@ class TestCustomAssertMsg(object):
a = 1 a = 1
b = 2 b = 2
assert A.a == b, ( assert (
"A.a appears not to be b\n" "or does not appear to be b\none of those" A.a == b
) ), "A.a appears not to be b\nor does not appear to be b\none of those"
def test_custom_repr(self): def test_custom_repr(self):
class JSON(object): class JSON(object):

View File

@ -582,7 +582,7 @@ get on the terminal - we are working on that)::
b = 2 b = 2
> assert ( > assert (
A.a == b A.a == b
), "A.a appears not to be b\n" "or does not appear to be b\none of those" ), "A.a appears not to be b\nor does not appear to be b\none of those"
E AssertionError: A.a appears not to be b E AssertionError: A.a appears not to be b
E or does not appear to be b E or does not appear to be b
E one of those E one of those

View File

@ -178,7 +178,7 @@ Mark a test function as using the given fixture names.
.. warning:: .. warning::
This mark can be used with *test functions* only, having no affect when applied This mark has no effect when applied
to a **fixture** function. to a **fixture** function.
.. py:function:: pytest.mark.usefixtures(*names) .. py:function:: pytest.mark.usefixtures(*names)

View File

@ -199,7 +199,7 @@ def _diff_text(left, right, verbose=False):
if i > 42: if i > 42:
i -= 10 # Provide some context i -= 10 # Provide some context
explanation = [ explanation = [
u("Skipping %s identical leading " "characters in diff, use -v to show") u("Skipping %s identical leading characters in diff, use -v to show")
% i % i
] ]
left = left[i:] left = left[i:]

View File

@ -343,7 +343,7 @@ def cacheshow(config, session):
key = valpath.relative_to(vdir) key = valpath.relative_to(vdir)
val = config.cache.get(key, dummy) val = config.cache.get(key, dummy)
if val is dummy: if val is dummy:
tw.line("%s contains unreadable content, " "will be ignored" % key) tw.line("%s contains unreadable content, will be ignored" % key)
else: else:
tw.line("%s contains:" % key) tw.line("%s contains:" % key)
for line in pformat(val).splitlines(): for line in pformat(val).splitlines():

View File

@ -654,7 +654,7 @@ class DontReadFromInput(six.Iterator):
return self return self
def fileno(self): def fileno(self):
raise UnsupportedOperation("redirected stdin is pseudofile, " "has no fileno()") raise UnsupportedOperation("redirected stdin is pseudofile, has no fileno()")
def isatty(self): def isatty(self):
return False return False

View File

@ -268,7 +268,7 @@ def get_real_func(obj):
obj = new_obj obj = new_obj
else: else:
raise ValueError( raise ValueError(
("could not find real function of {start}" "\nstopped at {current}").format( ("could not find real function of {start}\nstopped at {current}").format(
start=py.io.saferepr(start_obj), current=py.io.saferepr(obj) start=py.io.saferepr(start_obj), current=py.io.saferepr(obj)
) )
) )

View File

@ -92,7 +92,7 @@ RECORD_XML_PROPERTY = RemovedInPytest4Warning(
) )
COLLECTOR_MAKEITEM = RemovedInPytest4Warning( COLLECTOR_MAKEITEM = RemovedInPytest4Warning(
"pycollector makeitem was removed " "as it is an accidentially leaked internal api" "pycollector makeitem was removed as it is an accidentially leaked internal api"
) )
METAFUNC_ADD_CALL = RemovedInPytest4Warning( METAFUNC_ADD_CALL = RemovedInPytest4Warning(

View File

@ -139,7 +139,7 @@ def showhelp(config):
tw.line() tw.line()
tw.line() tw.line()
tw.line( tw.line(
"[pytest] ini-options in the first " "pytest.ini|tox.ini|setup.cfg file found:" "[pytest] ini-options in the first pytest.ini|tox.ini|setup.cfg file found:"
) )
tw.line() tw.line()

View File

@ -99,7 +99,7 @@ def pytest_addoption(parser):
"python_functions", "python_functions",
type="args", type="args",
default=["test"], default=["test"],
help="prefixes or glob names for Python test function and " "method discovery", help="prefixes or glob names for Python test function and method discovery",
) )
group.addoption( group.addoption(

View File

@ -175,7 +175,7 @@ class WarningsChecker(WarningsRecorder):
def __init__(self, expected_warning=None, match_expr=None): def __init__(self, expected_warning=None, match_expr=None):
super(WarningsChecker, self).__init__() super(WarningsChecker, self).__init__()
msg = "exceptions must be old-style classes or " "derived from Warning, not %s" msg = "exceptions must be old-style classes or derived from Warning, not %s"
if isinstance(expected_warning, tuple): if isinstance(expected_warning, tuple):
for exc in expected_warning: for exc in expected_warning:
if not inspect.isclass(exc): if not inspect.isclass(exc):

View File

@ -835,9 +835,7 @@ def repr_pythonversion(v=None):
def build_summary_stats_line(stats): def build_summary_stats_line(stats):
keys = ( keys = ("failed passed skipped deselected xfailed xpassed warnings error").split()
"failed passed skipped deselected " "xfailed xpassed warnings error"
).split()
unknown_key_seen = False unknown_key_seen = False
for key in stats.keys(): for key in stats.keys():
if key not in keys: if key not in keys:

View File

@ -628,7 +628,7 @@ class TestInvocationVariants(object):
lib = ns.mkdir(dirname) lib = ns.mkdir(dirname)
lib.ensure("__init__.py") lib.ensure("__init__.py")
lib.join("test_{}.py".format(dirname)).write( lib.join("test_{}.py".format(dirname)).write(
"def test_{}(): pass\n" "def test_other():pass".format(dirname) "def test_{}(): pass\ndef test_other():pass".format(dirname)
) )
# The structure of the test directory is now: # The structure of the test directory is now:
@ -717,10 +717,10 @@ class TestInvocationVariants(object):
lib = foo.mkdir("bar") lib = foo.mkdir("bar")
lib.ensure("__init__.py") lib.ensure("__init__.py")
lib.join("test_bar.py").write( lib.join("test_bar.py").write(
"def test_bar(): pass\n" "def test_other(a_fixture):pass" "def test_bar(): pass\ndef test_other(a_fixture):pass"
) )
lib.join("conftest.py").write( lib.join("conftest.py").write(
"import pytest\n" "@pytest.fixture\n" "def a_fixture():pass" "import pytest\n@pytest.fixture\ndef a_fixture():pass"
) )
d_local = testdir.mkdir("local") d_local = testdir.mkdir("local")

View File

@ -26,10 +26,10 @@ def test_coloredlogformatter():
formatter = ColoredLevelFormatter(tw, logfmt) formatter = ColoredLevelFormatter(tw, logfmt)
output = formatter.format(record) output = formatter.format(record)
assert output == ( assert output == (
"dummypath 10 " "\x1b[32mINFO \x1b[0m Test Message" "dummypath 10 \x1b[32mINFO \x1b[0m Test Message"
) )
tw.hasmarkup = False tw.hasmarkup = False
formatter = ColoredLevelFormatter(tw, logfmt) formatter = ColoredLevelFormatter(tw, logfmt)
output = formatter.format(record) output = formatter.format(record)
assert output == ("dummypath 10 " "INFO Test Message") assert output == ("dummypath 10 INFO Test Message")

View File

@ -476,7 +476,7 @@ class TestPython(object):
tnode.assert_attr( tnode.assert_attr(
file="test_junit_prefixing.py", file="test_junit_prefixing.py",
line="3", line="3",
classname="xyz.test_junit_prefixing." "TestHello", classname="xyz.test_junit_prefixing.TestHello",
name="test_hello", name="test_hello",
) )

View File

@ -147,7 +147,7 @@ class TestPDB(object):
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect(".*def test_1") child.expect(".*def test_1")
child.expect(".*i = 0") child.expect(".*i = 0")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -174,7 +174,7 @@ class TestPDB(object):
""" """
) )
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("(Pdb)") child.expect("Pdb")
child.sendline("p self.filename") child.sendline("p self.filename")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
@ -209,7 +209,7 @@ class TestPDB(object):
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("captured stdout") child.expect("captured stdout")
child.expect("get rekt") child.expect("get rekt")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -228,7 +228,7 @@ class TestPDB(object):
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("captured stderr") child.expect("captured stderr")
child.expect("get rekt") child.expect("get rekt")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -243,7 +243,7 @@ class TestPDB(object):
""" """
) )
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("(Pdb)") child.expect("Pdb")
output = child.before.decode("utf8") output = child.before.decode("utf8")
child.sendeof() child.sendeof()
assert "captured stdout" not in output assert "captured stdout" not in output
@ -266,7 +266,7 @@ class TestPDB(object):
if showcapture in ("all", "log"): if showcapture in ("all", "log"):
child.expect("captured log") child.expect("captured log")
child.expect("get rekt") child.expect("get rekt")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -281,13 +281,11 @@ class TestPDB(object):
assert False assert False
""" """
) )
child = testdir.spawn_pytest( child = testdir.spawn_pytest("--show-capture=all --pdb -p no:logging %s" % p1)
"--show-capture=all --pdb " "-p no:logging %s" % p1
)
child.expect("get rekt") child.expect("get rekt")
output = child.before.decode("utf8") output = child.before.decode("utf8")
assert "captured log" not in output assert "captured log" not in output
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -306,7 +304,7 @@ class TestPDB(object):
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect(".*def test_1") child.expect(".*def test_1")
child.expect(".*pytest.raises.*globalfunc") child.expect(".*pytest.raises.*globalfunc")
child.expect("(Pdb)") child.expect("Pdb")
child.sendline("globalfunc") child.sendline("globalfunc")
child.expect(".*function") child.expect(".*function")
child.sendeof() child.sendeof()
@ -322,7 +320,7 @@ class TestPDB(object):
) )
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
# child.expect(".*import pytest.*") # child.expect(".*import pytest.*")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
child.expect("1 error") child.expect("1 error")
self.flush(child) self.flush(child)
@ -337,7 +335,7 @@ class TestPDB(object):
p1 = testdir.makepyfile("def test_func(): pass") p1 = testdir.makepyfile("def test_func(): pass")
child = testdir.spawn_pytest("--pdb %s" % p1) child = testdir.spawn_pytest("--pdb %s" % p1)
# child.expect(".*import pytest.*") # child.expect(".*import pytest.*")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
self.flush(child) self.flush(child)
@ -355,7 +353,7 @@ class TestPDB(object):
child = testdir.spawn_pytest(str(p1)) child = testdir.spawn_pytest(str(p1))
child.expect("test_1") child.expect("test_1")
child.expect("x = 3") child.expect("x = 3")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf-8") rest = child.read().decode("utf-8")
assert "1 failed" in rest assert "1 failed" in rest
@ -373,7 +371,7 @@ class TestPDB(object):
) )
child = testdir.spawn_pytest(str(p1)) child = testdir.spawn_pytest(str(p1))
child.expect("test_1") child.expect("test_1")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -448,10 +446,10 @@ class TestPDB(object):
""" """
) )
child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1) child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1)
child.expect("(Pdb)") child.expect("Pdb")
child.sendline("i") child.sendline("i")
child.expect("0") child.expect("0")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -474,9 +472,10 @@ class TestPDB(object):
child = testdir.spawn_pytest(str(p1)) child = testdir.spawn_pytest(str(p1))
child.expect("test_1") child.expect("test_1")
child.expect("x = 3") child.expect("x = 3")
child.expect("(Pdb)") child.expect("Pdb")
child.sendline("c") child.sendline("c")
child.expect("x = 4") child.expect("x = 4")
child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -495,6 +494,7 @@ class TestPDB(object):
) )
child = testdir.spawn("{} {}".format(sys.executable, p1)) child = testdir.spawn("{} {}".format(sys.executable, p1))
child.expect("x = 5") child.expect("x = 5")
child.expect("Pdb")
child.sendeof() child.sendeof()
self.flush(child) self.flush(child)
@ -511,6 +511,7 @@ class TestPDB(object):
) )
child = testdir.spawn_pytest(str(p1)) child = testdir.spawn_pytest(str(p1))
child.expect("x = 5") child.expect("x = 5")
child.expect("Pdb")
child.sendeof() child.sendeof()
self.flush(child) self.flush(child)
@ -690,7 +691,7 @@ class TestDebuggingBreakpoints(object):
) )
child = testdir.spawn_pytest(str(p1)) child = testdir.spawn_pytest(str(p1))
child.expect("test_1") child.expect("test_1")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -710,7 +711,7 @@ class TestDebuggingBreakpoints(object):
) )
child = testdir.spawn_pytest(str(p1)) child = testdir.spawn_pytest(str(p1))
child.expect("test_1") child.expect("test_1")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 failed" in rest assert "1 failed" in rest
@ -728,7 +729,7 @@ class TestTraceOption:
) )
child = testdir.spawn_pytest("--trace " + str(p1)) child = testdir.spawn_pytest("--trace " + str(p1))
child.expect("test_1") child.expect("test_1")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 passed" in rest assert "1 passed" in rest
@ -747,7 +748,7 @@ class TestTraceOption:
) )
child = testdir.spawn_pytest("--trace " + str(p1)) child = testdir.spawn_pytest("--trace " + str(p1))
child.expect("is_equal") child.expect("is_equal")
child.expect("(Pdb)") child.expect("Pdb")
child.sendeof() child.sendeof()
rest = child.read().decode("utf8") rest = child.read().decode("utf8")
assert "1 passed" in rest assert "1 passed" in rest