Merge pull request #1605 from guyzmo/issue/1604
Fixed issue shadowing error when missing argument on teardown_method
This commit is contained in:
commit
66e66f61e8
1
AUTHORS
1
AUTHORS
|
@ -91,3 +91,4 @@ Thomas Grainger
|
||||||
Tom Viner
|
Tom Viner
|
||||||
Trevor Bekolay
|
Trevor Bekolay
|
||||||
Wouter van Ackooy
|
Wouter van Ackooy
|
||||||
|
Bernard Pratz
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
* Text documents without any doctests no longer appear as "skipped".
|
* Text documents without any doctests no longer appear as "skipped".
|
||||||
Thanks `@graingert`_ for reporting and providing a full PR (`#1580`_).
|
Thanks `@graingert`_ for reporting and providing a full PR (`#1580`_).
|
||||||
|
|
||||||
*
|
* Fix internal error issue when ``method`` argument is missing for
|
||||||
|
``teardown_method()``. Fixes (`#1605`_).
|
||||||
|
|
||||||
*
|
*
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
`@marscher`. Thanks `@nicoddemus` for his help.
|
`@marscher`. Thanks `@nicoddemus` for his help.
|
||||||
|
|
||||||
.. _#1580: https://github.com/pytest-dev/pytest/issues/1580
|
.. _#1580: https://github.com/pytest-dev/pytest/issues/1580
|
||||||
|
.. _#1605: https://github.com/pytest-dev/pytest/issues/1605
|
||||||
|
|
||||||
.. _@graingert: https://github.com/graingert
|
.. _@graingert: https://github.com/graingert
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,10 @@ class Node(object):
|
||||||
if self.config.option.fulltrace:
|
if self.config.option.fulltrace:
|
||||||
style="long"
|
style="long"
|
||||||
else:
|
else:
|
||||||
|
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
|
||||||
self._prunetraceback(excinfo)
|
self._prunetraceback(excinfo)
|
||||||
|
if len(excinfo.traceback) == 0:
|
||||||
|
excinfo.traceback = tb
|
||||||
tbfilter = False # prunetraceback already does it
|
tbfilter = False # prunetraceback already does it
|
||||||
if style == "auto":
|
if style == "auto":
|
||||||
style = "long"
|
style = "long"
|
||||||
|
|
|
@ -228,6 +228,39 @@ class BaseFunctionalTests:
|
||||||
assert reps[5].nodeid.endswith("test_func")
|
assert reps[5].nodeid.endswith("test_func")
|
||||||
assert reps[5].failed
|
assert reps[5].failed
|
||||||
|
|
||||||
|
def test_exact_teardown_issue1206(self, testdir):
|
||||||
|
rec = testdir.inline_runsource("""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
class TestClass:
|
||||||
|
def teardown_method(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_method(self):
|
||||||
|
assert True
|
||||||
|
""")
|
||||||
|
reps = rec.getreports("pytest_runtest_logreport")
|
||||||
|
print (reps)
|
||||||
|
assert len(reps) == 3
|
||||||
|
#
|
||||||
|
assert reps[0].nodeid.endswith("test_method")
|
||||||
|
assert reps[0].passed
|
||||||
|
assert reps[0].when == 'setup'
|
||||||
|
#
|
||||||
|
assert reps[1].nodeid.endswith("test_method")
|
||||||
|
assert reps[1].passed
|
||||||
|
assert reps[1].when == 'call'
|
||||||
|
#
|
||||||
|
assert reps[2].nodeid.endswith("test_method")
|
||||||
|
assert reps[2].failed
|
||||||
|
assert reps[2].when == "teardown"
|
||||||
|
assert reps[2].longrepr.reprcrash.message in (
|
||||||
|
# python3 error
|
||||||
|
'TypeError: teardown_method() takes 1 positional argument but 2 were given',
|
||||||
|
# python2 error
|
||||||
|
'TypeError: teardown_method() takes exactly 1 argument (2 given)'
|
||||||
|
)
|
||||||
|
|
||||||
def test_failure_in_setup_function_ignores_custom_repr(self, testdir):
|
def test_failure_in_setup_function_ignores_custom_repr(self, testdir):
|
||||||
testdir.makepyfile(conftest="""
|
testdir.makepyfile(conftest="""
|
||||||
import pytest
|
import pytest
|
||||||
|
|
Loading…
Reference in New Issue