Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ env:
- TOXENV=py36-numpy
- TOXENV=py36-pluggymaster PYTEST_NO_COVERAGE=1
- TOXENV=py27-nobyte
- TOXENV=doctesting
- TOXENV=docs PYTEST_NO_COVERAGE=1

jobs:
include:
Expand Down Expand Up @@ -61,7 +59,7 @@ jobs:
env: TOXENV=py27
- env: TOXENV=py34
- env: TOXENV=py36
- env: TOXENV=linting PYTEST_NO_COVERAGE=1
- env: TOXENV=linting,docs,doctesting PYTEST_NO_COVERAGE=1

- stage: deploy
python: '3.6'
Expand Down
5 changes: 1 addition & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
environment:
matrix:
- TOXENV: "linting"
- TOXENV: "linting,docs,doctesting"
PYTEST_NO_COVERAGE: "1"
- TOXENV: "py27"
- TOXENV: "py34"
Expand All @@ -20,11 +20,8 @@ environment:
- TOXENV: "py36-pluggymaster"
PYTEST_NO_COVERAGE: "1"
- TOXENV: "py27-nobyte"
- TOXENV: "doctesting"
- TOXENV: "py36-freeze"
PYTEST_NO_COVERAGE: "1"
- TOXENV: "docs"
PYTEST_NO_COVERAGE: "1"

install:
- echo Installed Pythons
Expand Down
1 change: 1 addition & 0 deletions changelog/3713.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update usefixtures documentation to clarify that it can't be used with fixture functions.
1 change: 1 addition & 0 deletions changelog/4093.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed formatting of string literals in internal tests.
6 changes: 3 additions & 3 deletions doc/en/example/assertion/failure_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ class A(object):
a = 1

b = 2
assert A.a == b, (
"A.a appears not to be b\n" "or does not appear to be b\none of those"
)
assert (
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):
class JSON(object):
Expand Down
2 changes: 1 addition & 1 deletion doc/en/example/reportingdemo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ get on the terminal - we are working on that)::
b = 2
> assert (
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 or does not appear to be b
E one of those
Expand Down
2 changes: 1 addition & 1 deletion doc/en/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Mark a test function as using the given fixture names.

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

.. py:function:: pytest.mark.usefixtures(*names)
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/assertion/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def escape_for_readable_diff(binary_text):
if i > 42:
i -= 10 # Provide some context
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
]
left = left[i:]
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/cacheprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def cacheshow(config, session):
key = valpath.relative_to(vdir)
val = config.cache.get(key, 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:
tw.line("%s contains:" % key)
for line in pformat(val).splitlines():
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def __iter__(self):
return 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):
return False
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def get_real_func(obj):
obj = new_obj
else:
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)
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
)

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(
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/helpconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def showhelp(config):
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()

Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def pytest_addoption(parser):
"python_functions",
type="args",
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(
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/recwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class WarningsChecker(WarningsRecorder):
def __init__(self, expected_warning=None, match_expr=None):
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):
for exc in expected_warning:
if not inspect.isclass(exc):
Expand Down
4 changes: 1 addition & 3 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,7 @@ def repr_pythonversion(v=None):


def build_summary_stats_line(stats):
keys = (
"failed passed skipped deselected " "xfailed xpassed warnings error"
).split()
keys = ("failed passed skipped deselected xfailed xpassed warnings error").split()
unknown_key_seen = False
for key in stats.keys():
if key not in keys:
Expand Down
6 changes: 3 additions & 3 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def test_cmdline_python_namespace_package(self, testdir, monkeypatch):
lib = ns.mkdir(dirname)
lib.ensure("__init__.py")
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:
Expand Down Expand Up @@ -697,10 +697,10 @@ def test_cmdline_python_package_symlink(self, testdir, monkeypatch):
lib = foo.mkdir("bar")
lib.ensure("__init__.py")
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(
"import pytest\n" "@pytest.fixture\n" "def a_fixture():pass"
"import pytest\[email protected]\ndef a_fixture():pass"
)

d_local = testdir.mkdir("local")
Expand Down
4 changes: 2 additions & 2 deletions testing/logging/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class option(object):
formatter = ColoredLevelFormatter(tw, logfmt)
output = formatter.format(record)
assert output == (
"dummypath 10 " "\x1b[32mINFO \x1b[0m Test Message"
"dummypath 10 \x1b[32mINFO \x1b[0m Test Message"
)

tw.hasmarkup = False
formatter = ColoredLevelFormatter(tw, logfmt)
output = formatter.format(record)
assert output == ("dummypath 10 " "INFO Test Message")
assert output == ("dummypath 10 INFO Test Message")
2 changes: 1 addition & 1 deletion testing/test_junitxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def test_hello(self):
tnode.assert_attr(
file="test_junit_prefixing.py",
line="3",
classname="xyz.test_junit_prefixing." "TestHello",
classname="xyz.test_junit_prefixing.TestHello",
name="test_hello",
)

Expand Down
45 changes: 23 additions & 22 deletions testing/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_1():
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect(".*def test_1")
child.expect(".*i = 0")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -174,7 +174,7 @@ def test_false(self):
"""
)
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("(Pdb)")
child.expect("Pdb")
child.sendline("p self.filename")
child.sendeof()
rest = child.read().decode("utf8")
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_1():
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("captured stdout")
child.expect("get rekt")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -228,7 +228,7 @@ def test_1():
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("captured stderr")
child.expect("get rekt")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -243,7 +243,7 @@ def test_1():
"""
)
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect("(Pdb)")
child.expect("Pdb")
output = child.before.decode("utf8")
child.sendeof()
assert "captured stdout" not in output
Expand All @@ -266,7 +266,7 @@ def test_1():
if showcapture in ("all", "log"):
child.expect("captured log")
child.expect("get rekt")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -281,13 +281,11 @@ def test_1():
assert False
"""
)
child = testdir.spawn_pytest(
"--show-capture=all --pdb " "-p no:logging %s" % p1
)
child = testdir.spawn_pytest("--show-capture=all --pdb -p no:logging %s" % p1)
child.expect("get rekt")
output = child.before.decode("utf8")
assert "captured log" not in output
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -306,7 +304,7 @@ def test_1():
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect(".*def test_1")
child.expect(".*pytest.raises.*globalfunc")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendline("globalfunc")
child.expect(".*function")
child.sendeof()
Expand All @@ -322,7 +320,7 @@ def test_pdb_interaction_on_collection_issue181(self, testdir):
)
child = testdir.spawn_pytest("--pdb %s" % p1)
# child.expect(".*import pytest.*")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
child.expect("1 error")
self.flush(child)
Expand All @@ -337,7 +335,7 @@ def pytest_runtest_protocol():
p1 = testdir.makepyfile("def test_func(): pass")
child = testdir.spawn_pytest("--pdb %s" % p1)
# child.expect(".*import pytest.*")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
self.flush(child)

Expand All @@ -355,7 +353,7 @@ def test_1():
child = testdir.spawn_pytest(str(p1))
child.expect("test_1")
child.expect("x = 3")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf-8")
assert "1 failed" in rest
Expand All @@ -373,7 +371,7 @@ def test_1():
)
child = testdir.spawn_pytest(str(p1))
child.expect("test_1")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand Down Expand Up @@ -448,10 +446,10 @@ def function_1():
"""
)
child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1)
child.expect("(Pdb)")
child.expect("Pdb")
child.sendline("i")
child.expect("0")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -474,9 +472,10 @@ def test_1():
child = testdir.spawn_pytest(str(p1))
child.expect("test_1")
child.expect("x = 3")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendline("c")
child.expect("x = 4")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -495,6 +494,7 @@ def test_pdb_used_outside_test(self, testdir):
)
child = testdir.spawn("{} {}".format(sys.executable, p1))
child.expect("x = 5")
child.expect("Pdb")
child.sendeof()
self.flush(child)

Expand All @@ -511,6 +511,7 @@ def test_foo(a):
)
child = testdir.spawn_pytest(str(p1))
child.expect("x = 5")
child.expect("Pdb")
child.sendeof()
self.flush(child)

Expand Down Expand Up @@ -690,7 +691,7 @@ def test_1():
)
child = testdir.spawn_pytest(str(p1))
child.expect("test_1")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -710,7 +711,7 @@ def test_1():
)
child = testdir.spawn_pytest(str(p1))
child.expect("test_1")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
Expand All @@ -728,7 +729,7 @@ def test_1():
)
child = testdir.spawn_pytest("--trace " + str(p1))
child.expect("test_1")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 passed" in rest
Expand All @@ -747,7 +748,7 @@ def test_1():
)
child = testdir.spawn_pytest("--trace " + str(p1))
child.expect("is_equal")
child.expect("(Pdb)")
child.expect("Pdb")
child.sendeof()
rest = child.read().decode("utf8")
assert "1 passed" in rest
Expand Down