Merge pull request #4851 from blueyed/addopts-vv
ci: PYTEST_ADDOPTS=-vv
This commit is contained in:
commit
6eff3069da
13
.travis.yml
13
.travis.yml
|
@ -6,8 +6,13 @@ stages:
|
||||||
if: repo = pytest-dev/pytest AND tag IS NOT present
|
if: repo = pytest-dev/pytest AND tag IS NOT present
|
||||||
- name: deploy
|
- name: deploy
|
||||||
if: repo = pytest-dev/pytest AND tag IS present
|
if: repo = pytest-dev/pytest AND tag IS present
|
||||||
python:
|
python: '3.7'
|
||||||
- '3.7'
|
cache: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- PYTEST_ADDOPTS=-vv
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- python -m pip install --upgrade --pre tox
|
- python -m pip install --upgrade --pre tox
|
||||||
|
|
||||||
|
@ -57,7 +62,8 @@ jobs:
|
||||||
# - pytester's LsofFdLeakChecker
|
# - pytester's LsofFdLeakChecker
|
||||||
# - TestArgComplete (linux only)
|
# - TestArgComplete (linux only)
|
||||||
# - numpy
|
# - numpy
|
||||||
- env: TOXENV=py37-lsof-numpy-xdist PYTEST_COVERAGE=1
|
# Empty PYTEST_ADDOPTS to run this non-verbose.
|
||||||
|
- env: TOXENV=py37-lsof-numpy-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS=
|
||||||
|
|
||||||
# Specialized factors for py27.
|
# Specialized factors for py27.
|
||||||
- env: TOXENV=py27-nobyte-numpy-xdist
|
- env: TOXENV=py27-nobyte-numpy-xdist
|
||||||
|
@ -147,4 +153,3 @@ notifications:
|
||||||
skip_join: true
|
skip_join: true
|
||||||
email:
|
email:
|
||||||
- pytest-commit@python.org
|
- pytest-commit@python.org
|
||||||
cache: false
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ trigger:
|
||||||
- features
|
- features
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml"
|
PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml -vv"
|
||||||
python.needs_vc: False
|
python.needs_vc: False
|
||||||
python.exe: "python"
|
python.exe: "python"
|
||||||
COVERAGE_FILE: "$(Build.Repository.LocalPath)/.coverage"
|
COVERAGE_FILE: "$(Build.Repository.LocalPath)/.coverage"
|
||||||
|
|
|
@ -127,7 +127,7 @@ class TestAssertionRewrite(object):
|
||||||
result = testdir.runpytest_subprocess()
|
result = testdir.runpytest_subprocess()
|
||||||
assert "warnings" not in "".join(result.outlines)
|
assert "warnings" not in "".join(result.outlines)
|
||||||
|
|
||||||
def test_name(self):
|
def test_name(self, request):
|
||||||
def f():
|
def f():
|
||||||
assert False
|
assert False
|
||||||
|
|
||||||
|
@ -147,17 +147,41 @@ class TestAssertionRewrite(object):
|
||||||
def f():
|
def f():
|
||||||
assert sys == 42
|
assert sys == 42
|
||||||
|
|
||||||
assert getmsg(f, {"sys": sys}) == "assert sys == 42"
|
verbose = request.config.getoption("verbose")
|
||||||
|
msg = getmsg(f, {"sys": sys})
|
||||||
|
if verbose > 0:
|
||||||
|
assert msg == (
|
||||||
|
"assert <module 'sys' (built-in)> == 42\n"
|
||||||
|
" -<module 'sys' (built-in)>\n"
|
||||||
|
" +42"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
assert msg == "assert sys == 42"
|
||||||
|
|
||||||
def f():
|
def f():
|
||||||
assert cls == 42 # noqa
|
assert cls == 42 # noqa: F821
|
||||||
|
|
||||||
class X(object):
|
class X(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
assert getmsg(f, {"cls": X}) == "assert cls == 42"
|
msg = getmsg(f, {"cls": X}).splitlines()
|
||||||
|
if verbose > 0:
|
||||||
|
if six.PY2:
|
||||||
|
assert msg == [
|
||||||
|
"assert <class 'test_assertrewrite.X'> == 42",
|
||||||
|
" -<class 'test_assertrewrite.X'>",
|
||||||
|
" +42",
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
assert msg == [
|
||||||
|
"assert <class 'test_...e.<locals>.X'> == 42",
|
||||||
|
" -<class 'test_assertrewrite.TestAssertionRewrite.test_name.<locals>.X'>",
|
||||||
|
" +42",
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
assert msg == ["assert cls == 42"]
|
||||||
|
|
||||||
def test_dont_rewrite_if_hasattr_fails(self):
|
def test_dont_rewrite_if_hasattr_fails(self, request):
|
||||||
class Y(object):
|
class Y(object):
|
||||||
""" A class whos getattr fails, but not with `AttributeError` """
|
""" A class whos getattr fails, but not with `AttributeError` """
|
||||||
|
|
||||||
|
@ -173,10 +197,16 @@ class TestAssertionRewrite(object):
|
||||||
def f():
|
def f():
|
||||||
assert cls().foo == 2 # noqa
|
assert cls().foo == 2 # noqa
|
||||||
|
|
||||||
message = getmsg(f, {"cls": Y})
|
# XXX: looks like the "where" should also be there in verbose mode?!
|
||||||
assert "assert 3 == 2" in message
|
message = getmsg(f, {"cls": Y}).splitlines()
|
||||||
assert "+ where 3 = Y.foo" in message
|
if request.config.getoption("verbose") > 0:
|
||||||
assert "+ where Y = cls()" in message
|
assert message == ["assert 3 == 2", " -3", " +2"]
|
||||||
|
else:
|
||||||
|
assert message == [
|
||||||
|
"assert 3 == 2",
|
||||||
|
" + where 3 = Y.foo",
|
||||||
|
" + where Y = cls()",
|
||||||
|
]
|
||||||
|
|
||||||
def test_assert_already_has_message(self):
|
def test_assert_already_has_message(self):
|
||||||
def f():
|
def f():
|
||||||
|
@ -552,15 +582,16 @@ class TestAssertionRewrite(object):
|
||||||
|
|
||||||
getmsg(f, must_pass=True)
|
getmsg(f, must_pass=True)
|
||||||
|
|
||||||
def test_len(self):
|
def test_len(self, request):
|
||||||
def f():
|
def f():
|
||||||
values = list(range(10))
|
values = list(range(10))
|
||||||
assert len(values) == 11
|
assert len(values) == 11
|
||||||
|
|
||||||
assert getmsg(f).startswith(
|
msg = getmsg(f)
|
||||||
"""assert 10 == 11
|
if request.config.getoption("verbose") > 0:
|
||||||
+ where 10 = len(["""
|
assert msg == "assert 10 == 11\n -10\n +11"
|
||||||
)
|
else:
|
||||||
|
assert msg == "assert 10 == 11\n + where 10 = len([0, 1, 2, 3, 4, 5, ...])"
|
||||||
|
|
||||||
def test_custom_reprcompare(self, monkeypatch):
|
def test_custom_reprcompare(self, monkeypatch):
|
||||||
def my_reprcompare(op, left, right):
|
def my_reprcompare(op, left, right):
|
||||||
|
@ -608,7 +639,7 @@ class TestAssertionRewrite(object):
|
||||||
|
|
||||||
assert getmsg(f).startswith("assert '%test' == 'test'")
|
assert getmsg(f).startswith("assert '%test' == 'test'")
|
||||||
|
|
||||||
def test_custom_repr(self):
|
def test_custom_repr(self, request):
|
||||||
def f():
|
def f():
|
||||||
class Foo(object):
|
class Foo(object):
|
||||||
a = 1
|
a = 1
|
||||||
|
@ -619,7 +650,11 @@ class TestAssertionRewrite(object):
|
||||||
f = Foo()
|
f = Foo()
|
||||||
assert 0 == f.a
|
assert 0 == f.a
|
||||||
|
|
||||||
assert r"where 1 = \n{ \n~ \n}.a" in util._format_lines([getmsg(f)])[0]
|
lines = util._format_lines([getmsg(f)])
|
||||||
|
if request.config.getoption("verbose") > 0:
|
||||||
|
assert lines == ["assert 0 == 1\n -0\n +1"]
|
||||||
|
else:
|
||||||
|
assert lines == ["assert 0 == 1\n + where 1 = \\n{ \\n~ \\n}.a"]
|
||||||
|
|
||||||
def test_custom_repr_non_ascii(self):
|
def test_custom_repr_non_ascii(self):
|
||||||
def f():
|
def f():
|
||||||
|
|
Loading…
Reference in New Issue