diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 891b75a51..517c81ecb 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,50 @@ .. towncrier release notes start +Pytest 3.6.1 (2018-06-05) +========================= + +Bug Fixes +--------- + +- Fixed a bug where stdout and stderr were logged twice by junitxml when a test + was marked xfail. (`#3491 + `_) + +- Fix ``usefixtures`` mark applyed to unittest tests by correctly instantiating + ``FixtureInfo``. (`#3498 + `_) + +- Fix assertion rewriter compatibility with libraries that monkey patch + ``file`` objects. (`#3503 + `_) + + +Improved Documentation +---------------------- + +- Added a section on how to use fixtures as factories to the fixture + documentation. (`#3461 `_) + + +Trivial/Internal Changes +------------------------ + +- Enable caching for pip/pre-commit in order to reduce build time on + travis/appveyor. (`#3502 + `_) + +- Switch pytest to the src/ layout as we already suggested it for good practice + - now we implement it as well. (`#3513 + `_) + +- Fix if in tests to support 3.7.0b5, where a docstring handling in AST got + reverted. (`#3530 `_) + +- Remove some python2.5 compatibility code. (`#3629 + `_) + + Pytest 3.6.0 (2018-05-23) ========================= diff --git a/changelog/3461.doc.rst b/changelog/3461.doc.rst deleted file mode 100644 index 930b6565f..000000000 --- a/changelog/3461.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Added a section on how to use fixtures as factories to the fixture documentation. diff --git a/changelog/3491.bugfix.rst b/changelog/3491.bugfix.rst deleted file mode 100644 index 4c2507b85..000000000 --- a/changelog/3491.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed a bug where stdout and stderr were logged twice by junitxml when a test was marked xfail. diff --git a/changelog/3498.bugfix b/changelog/3498.bugfix deleted file mode 100644 index 344038bee..000000000 --- a/changelog/3498.bugfix +++ /dev/null @@ -1 +0,0 @@ -Fix ``usefixtures`` mark applyed to unittest tests by correctly instantiating ``FixtureInfo``. diff --git a/changelog/3502.trivial.rst b/changelog/3502.trivial.rst deleted file mode 100644 index 3ac2a57ab..000000000 --- a/changelog/3502.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Enable caching for pip/pre-commit in order to reduce build time on travis/appveyor. diff --git a/changelog/3503.bugfix.rst b/changelog/3503.bugfix.rst deleted file mode 100644 index e3ffdfaaf..000000000 --- a/changelog/3503.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fix assertion rewriter compatibility with libraries that monkey patch ``file`` objects. diff --git a/changelog/3513.trivial.rst b/changelog/3513.trivial.rst deleted file mode 100644 index e8c0948e0..000000000 --- a/changelog/3513.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Switch pytest to the src/ layout as we already suggested it for good practice - now we implement it as well. diff --git a/changelog/3530.trivial.rst b/changelog/3530.trivial.rst deleted file mode 100644 index 8ae10bb78..000000000 --- a/changelog/3530.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Fix if in tests to support 3.7.0b5, where a docstring handling in AST got reverted. diff --git a/changelog/3629.trivial.rst b/changelog/3629.trivial.rst deleted file mode 100644 index b6bb73fd1..000000000 --- a/changelog/3629.trivial.rst +++ /dev/null @@ -1 +0,0 @@ -Remove some python2.5 compatibility code. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index 8d1c2bd8f..09840708d 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-3.6.1 release-3.6.0 release-3.5.1 release-3.5.0 diff --git a/doc/en/announce/release-3.6.1.rst b/doc/en/announce/release-3.6.1.rst new file mode 100644 index 000000000..3bedcf46a --- /dev/null +++ b/doc/en/announce/release-3.6.1.rst @@ -0,0 +1,24 @@ +pytest-3.6.1 +======================================= + +pytest 3.6.1 has just been released to PyPI. + +This is a bug-fix release, being a drop-in replacement. To upgrade:: + + pip install --upgrade pytest + +The full changelog is available at http://doc.pytest.org/en/latest/changelog.html. + +Thanks to all who contributed to this release, among them: + +* Anthony Sottile +* Bruno Oliveira +* Jeffrey Rackauckas +* Miro HronĨok +* Niklas Meinzer +* Oliver Bestwalter +* Ronny Pfannschmidt + + +Happy testing, +The pytest Development Team diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 010d9c143..9e9d65b6d 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -26,14 +26,16 @@ get on the terminal - we are working on that):: > assert param1 * 2 < param2 E assert (3 * 2) < 6 - failure_demo.py:16: AssertionError + failure_demo.py:19: AssertionError _________________________ TestFailing.test_simple __________________________ self = def test_simple(self): + def f(): return 42 + def g(): return 43 @@ -42,83 +44,82 @@ get on the terminal - we are working on that):: E + where 42 = .f at 0xdeadbeef>() E + and 43 = .g at 0xdeadbeef>() - failure_demo.py:29: AssertionError + failure_demo.py:37: AssertionError ____________________ TestFailing.test_simple_multiline _____________________ self = def test_simple_multiline(self): - otherfunc_multi( - 42, - > 6*9) + > otherfunc_multi(42, 6 * 9) - failure_demo.py:34: + failure_demo.py:40: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 42, b = 54 - def otherfunc_multi(a,b): - > assert (a == - b) + def otherfunc_multi(a, b): + > assert a == b E assert 42 == 54 - failure_demo.py:12: AssertionError + failure_demo.py:15: AssertionError ___________________________ TestFailing.test_not ___________________________ self = def test_not(self): + def f(): return 42 + > assert not f() E assert not 42 E + where 42 = .f at 0xdeadbeef>() - failure_demo.py:39: AssertionError + failure_demo.py:47: AssertionError _________________ TestSpecialisedExplanations.test_eq_text _________________ self = def test_eq_text(self): - > assert 'spam' == 'eggs' + > assert "spam" == "eggs" E AssertionError: assert 'spam' == 'eggs' E - spam E + eggs - failure_demo.py:43: AssertionError + failure_demo.py:53: AssertionError _____________ TestSpecialisedExplanations.test_eq_similar_text _____________ self = def test_eq_similar_text(self): - > assert 'foo 1 bar' == 'foo 2 bar' + > assert "foo 1 bar" == "foo 2 bar" E AssertionError: assert 'foo 1 bar' == 'foo 2 bar' E - foo 1 bar E ? ^ E + foo 2 bar E ? ^ - failure_demo.py:46: AssertionError + failure_demo.py:56: AssertionError ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________ self = def test_eq_multiline_text(self): - > assert 'foo\nspam\nbar' == 'foo\neggs\nbar' + > assert "foo\nspam\nbar" == "foo\neggs\nbar" E AssertionError: assert 'foo\nspam\nbar' == 'foo\neggs\nbar' E foo E - spam E + eggs E bar - failure_demo.py:49: AssertionError + failure_demo.py:59: AssertionError ______________ TestSpecialisedExplanations.test_eq_long_text _______________ self = def test_eq_long_text(self): - a = '1'*100 + 'a' + '2'*100 - b = '1'*100 + 'b' + '2'*100 + a = "1" * 100 + "a" + "2" * 100 + b = "1" * 100 + "b" + "2" * 100 > assert a == b E AssertionError: assert '111111111111...2222222222222' == '1111111111111...2222222222222' E Skipping 90 identical leading characters in diff, use -v to show @@ -128,14 +129,14 @@ get on the terminal - we are working on that):: E + 1111111111b222222222 E ? ^ - failure_demo.py:54: AssertionError + failure_demo.py:64: AssertionError _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________ self = def test_eq_long_text_multiline(self): - a = '1\n'*100 + 'a' + '2\n'*100 - b = '1\n'*100 + 'b' + '2\n'*100 + a = "1\n" * 100 + "a" + "2\n" * 100 + b = "1\n" * 100 + "b" + "2\n" * 100 > assert a == b E AssertionError: assert '1\n1\n1\n1\n...n2\n2\n2\n2\n' == '1\n1\n1\n1\n1...n2\n2\n2\n2\n' E Skipping 190 identical leading characters in diff, use -v to show @@ -148,7 +149,7 @@ get on the terminal - we are working on that):: E E ...Full output truncated (7 lines hidden), use '-vv' to show - failure_demo.py:59: AssertionError + failure_demo.py:69: AssertionError _________________ TestSpecialisedExplanations.test_eq_list _________________ self = @@ -159,26 +160,26 @@ get on the terminal - we are working on that):: E At index 2 diff: 2 != 3 E Use -v to get the full diff - failure_demo.py:62: AssertionError + failure_demo.py:72: AssertionError ______________ TestSpecialisedExplanations.test_eq_list_long _______________ self = def test_eq_list_long(self): - a = [0]*100 + [1] + [3]*100 - b = [0]*100 + [2] + [3]*100 + a = [0] * 100 + [1] + [3] * 100 + b = [0] * 100 + [2] + [3] * 100 > assert a == b E assert [0, 0, 0, 0, 0, 0, ...] == [0, 0, 0, 0, 0, 0, ...] E At index 100 diff: 1 != 2 E Use -v to get the full diff - failure_demo.py:67: AssertionError + failure_demo.py:77: AssertionError _________________ TestSpecialisedExplanations.test_eq_dict _________________ self = def test_eq_dict(self): - > assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0} + > assert {"a": 0, "b": 1, "c": 0} == {"a": 0, "b": 2, "d": 0} E AssertionError: assert {'a': 0, 'b': 1, 'c': 0} == {'a': 0, 'b': 2, 'd': 0} E Omitting 1 identical items, use -vv to show E Differing items: @@ -190,13 +191,13 @@ get on the terminal - we are working on that):: E E ...Full output truncated (2 lines hidden), use '-vv' to show - failure_demo.py:70: AssertionError + failure_demo.py:80: AssertionError _________________ TestSpecialisedExplanations.test_eq_set __________________ self = def test_eq_set(self): - > assert set([0, 10, 11, 12]) == set([0, 20, 21]) + > assert {0, 10, 11, 12} == {0, 20, 21} E AssertionError: assert {0, 10, 11, 12} == {0, 20, 21} E Extra items in the left set: E 10 @@ -208,18 +209,18 @@ get on the terminal - we are working on that):: E E ...Full output truncated (2 lines hidden), use '-vv' to show - failure_demo.py:73: AssertionError + failure_demo.py:83: AssertionError _____________ TestSpecialisedExplanations.test_eq_longer_list ______________ self = def test_eq_longer_list(self): - > assert [1,2] == [1,2,3] + > assert [1, 2] == [1, 2, 3] E assert [1, 2] == [1, 2, 3] E Right contains more items, first extra item: 3 E Use -v to get the full diff - failure_demo.py:76: AssertionError + failure_demo.py:86: AssertionError _________________ TestSpecialisedExplanations.test_in_list _________________ self = @@ -228,14 +229,14 @@ get on the terminal - we are working on that):: > assert 1 in [0, 2, 3, 4, 5] E assert 1 in [0, 2, 3, 4, 5] - failure_demo.py:79: AssertionError + failure_demo.py:89: AssertionError __________ TestSpecialisedExplanations.test_not_in_text_multiline __________ self = def test_not_in_text_multiline(self): - text = 'some multiline\ntext\nwhich\nincludes foo\nand a\ntail' - > assert 'foo' not in text + text = "some multiline\ntext\nwhich\nincludes foo\nand a\ntail" + > assert "foo" not in text E AssertionError: assert 'foo' not in 'some multiline\ntext\nw...ncludes foo\nand a\ntail' E 'foo' is contained here: E some multiline @@ -247,95 +248,106 @@ get on the terminal - we are working on that):: E E ...Full output truncated (2 lines hidden), use '-vv' to show - failure_demo.py:83: AssertionError + failure_demo.py:93: AssertionError ___________ TestSpecialisedExplanations.test_not_in_text_single ____________ self = def test_not_in_text_single(self): - text = 'single foo line' - > assert 'foo' not in text + text = "single foo line" + > assert "foo" not in text E AssertionError: assert 'foo' not in 'single foo line' E 'foo' is contained here: E single foo line E ? +++ - failure_demo.py:87: AssertionError + failure_demo.py:97: AssertionError _________ TestSpecialisedExplanations.test_not_in_text_single_long _________ self = def test_not_in_text_single_long(self): - text = 'head ' * 50 + 'foo ' + 'tail ' * 20 - > assert 'foo' not in text + text = "head " * 50 + "foo " + "tail " * 20 + > assert "foo" not in text E AssertionError: assert 'foo' not in 'head head head head hea...ail tail tail tail tail ' E 'foo' is contained here: E head head foo tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail E ? +++ - failure_demo.py:91: AssertionError + failure_demo.py:101: AssertionError ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______ self = def test_not_in_text_single_long_term(self): - text = 'head ' * 50 + 'f'*70 + 'tail ' * 20 - > assert 'f'*70 not in text + text = "head " * 50 + "f" * 70 + "tail " * 20 + > assert "f" * 70 not in text E AssertionError: assert 'fffffffffff...ffffffffffff' not in 'head head he...l tail tail ' E 'ffffffffffffffffff...fffffffffffffffffff' is contained here: E head head fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffftail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail tail E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - failure_demo.py:95: AssertionError + failure_demo.py:105: AssertionError ______________________________ test_attribute ______________________________ def test_attribute(): + class Foo(object): b = 1 + i = Foo() > assert i.b == 2 E assert 1 == 2 E + where 1 = .Foo object at 0xdeadbeef>.b - failure_demo.py:102: AssertionError + failure_demo.py:114: AssertionError _________________________ test_attribute_instance __________________________ def test_attribute_instance(): + class Foo(object): b = 1 + > assert Foo().b == 2 E AssertionError: assert 1 == 2 E + where 1 = .Foo object at 0xdeadbeef>.b E + where .Foo object at 0xdeadbeef> = .Foo'>() - failure_demo.py:108: AssertionError + failure_demo.py:122: AssertionError __________________________ test_attribute_failure __________________________ def test_attribute_failure(): + class Foo(object): + def _get_b(self): - raise Exception('Failed to get attrib') + raise Exception("Failed to get attrib") + b = property(_get_b) + i = Foo() > assert i.b == 2 - failure_demo.py:117: + failure_demo.py:135: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = .Foo object at 0xdeadbeef> def _get_b(self): - > raise Exception('Failed to get attrib') + > raise Exception("Failed to get attrib") E Exception: Failed to get attrib - failure_demo.py:114: Exception + failure_demo.py:130: Exception _________________________ test_attribute_multiple __________________________ def test_attribute_multiple(): + class Foo(object): b = 1 + class Bar(object): b = 2 + > assert Foo().b == Bar().b E AssertionError: assert 1 == 2 E + where 1 = .Foo object at 0xdeadbeef>.b @@ -343,22 +355,22 @@ get on the terminal - we are working on that):: E + and 2 = .Bar object at 0xdeadbeef>.b E + where .Bar object at 0xdeadbeef> = .Bar'>() - failure_demo.py:125: AssertionError + failure_demo.py:146: AssertionError __________________________ TestRaises.test_raises __________________________ self = def test_raises(self): - s = 'qwe' + s = "qwe" # NOQA > raises(TypeError, "int(s)") - failure_demo.py:134: + failure_demo.py:157: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ > int(s) E ValueError: invalid literal for int() with base 10: 'qwe' - <0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python_api.py:615>:1: ValueError + <0-codegen $PYTHON_PREFIX/lib/python3.5/site-packages/_pytest/python_api.py:634>:1: ValueError ______________________ TestRaises.test_raises_doesnt _______________________ self = @@ -367,7 +379,7 @@ get on the terminal - we are working on that):: > raises(IOError, "int('3')") E Failed: DID NOT RAISE - failure_demo.py:137: Failed + failure_demo.py:160: Failed __________________________ TestRaises.test_raise ___________________________ self = @@ -376,103 +388,107 @@ get on the terminal - we are working on that):: > raise ValueError("demo error") E ValueError: demo error - failure_demo.py:140: ValueError + failure_demo.py:163: ValueError ________________________ TestRaises.test_tupleerror ________________________ self = def test_tupleerror(self): - > a,b = [1] + > a, b = [1] # NOQA E ValueError: not enough values to unpack (expected 2, got 1) - failure_demo.py:143: ValueError + failure_demo.py:166: ValueError ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______ self = def test_reinterpret_fails_with_print_for_the_fun_of_it(self): - l = [1,2,3] - print ("l is %r" % l) - > a,b = l.pop() + items = [1, 2, 3] + print("items is %r" % items) + > a, b = items.pop() E TypeError: 'int' object is not iterable - failure_demo.py:148: TypeError + failure_demo.py:171: TypeError --------------------------- Captured stdout call --------------------------- - l is [1, 2, 3] + items is [1, 2, 3] ________________________ TestRaises.test_some_error ________________________ self = def test_some_error(self): - > if namenotexi: + > if namenotexi: # NOQA E NameError: name 'namenotexi' is not defined - failure_demo.py:151: NameError + failure_demo.py:174: NameError ____________________ test_dynamic_compile_shows_nicely _____________________ def test_dynamic_compile_shows_nicely(): import imp import sys - src = 'def foo():\n assert 1 == 0\n' - name = 'abc-123' + + src = "def foo():\n assert 1 == 0\n" + name = "abc-123" module = imp.new_module(name) - code = _pytest._code.compile(src, name, 'exec') + code = _pytest._code.compile(src, name, "exec") py.builtin.exec_(code, module.__dict__) sys.modules[name] = module > module.foo() - failure_demo.py:168: + failure_demo.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def foo(): > assert 1 == 0 E AssertionError - <2-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:165>:2: AssertionError + <2-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:189>:2: AssertionError ____________________ TestMoreErrors.test_complex_error _____________________ self = def test_complex_error(self): + def f(): return 44 + def g(): return 43 + > somefunc(f(), g()) - failure_demo.py:178: + failure_demo.py:205: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - failure_demo.py:9: in somefunc - otherfunc(x,y) + failure_demo.py:11: in somefunc + otherfunc(x, y) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 44, b = 43 - def otherfunc(a,b): - > assert a==b + def otherfunc(a, b): + > assert a == b E assert 44 == 43 - failure_demo.py:6: AssertionError + failure_demo.py:7: AssertionError ___________________ TestMoreErrors.test_z1_unpack_error ____________________ self = def test_z1_unpack_error(self): - l = [] - > a,b = l + items = [] + > a, b = items E ValueError: not enough values to unpack (expected 2, got 0) - failure_demo.py:182: ValueError + failure_demo.py:209: ValueError ____________________ TestMoreErrors.test_z2_type_error _____________________ self = def test_z2_type_error(self): - l = 3 - > a,b = l + items = 3 + > a, b = items E TypeError: 'int' object is not iterable - failure_demo.py:186: TypeError + failure_demo.py:213: TypeError ______________________ TestMoreErrors.test_startswith ______________________ self = @@ -485,16 +501,19 @@ get on the terminal - we are working on that):: E + where False = ('456') E + where = '123'.startswith - failure_demo.py:191: AssertionError + failure_demo.py:218: AssertionError __________________ TestMoreErrors.test_startswith_nested ___________________ self = def test_startswith_nested(self): + def f(): return "123" + def g(): return "456" + > assert f().startswith(g()) E AssertionError: assert False E + where False = ('456') @@ -502,7 +521,7 @@ get on the terminal - we are working on that):: E + where '123' = .f at 0xdeadbeef>() E + and '456' = .g at 0xdeadbeef>() - failure_demo.py:198: AssertionError + failure_demo.py:228: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ self = @@ -513,18 +532,18 @@ get on the terminal - we are working on that):: E + where False = isinstance(43, float) E + where 43 = globf(42) - failure_demo.py:201: AssertionError + failure_demo.py:231: AssertionError _______________________ TestMoreErrors.test_instance _______________________ self = def test_instance(self): - self.x = 6*7 + self.x = 6 * 7 > assert self.x != 42 E assert 42 != 42 E + where 42 = .x - failure_demo.py:205: AssertionError + failure_demo.py:235: AssertionError _______________________ TestMoreErrors.test_compare ________________________ self = @@ -534,7 +553,7 @@ get on the terminal - we are working on that):: E assert 11 < 5 E + where 11 = globf(10) - failure_demo.py:208: AssertionError + failure_demo.py:238: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ self = @@ -545,47 +564,55 @@ get on the terminal - we are working on that):: > assert x == 0 E assert 1 == 0 - failure_demo.py:213: AssertionError + failure_demo.py:243: AssertionError ___________________ TestCustomAssertMsg.test_single_line ___________________ self = def test_single_line(self): + class A(object): a = 1 + b = 2 > assert A.a == b, "A.a appears not to be b" E AssertionError: A.a appears not to be b E assert 1 == 2 E + where 1 = .A'>.a - failure_demo.py:224: AssertionError + failure_demo.py:256: AssertionError ____________________ TestCustomAssertMsg.test_multiline ____________________ self = def test_multiline(self): + 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\n" "or 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 E assert 1 == 2 E + where 1 = .A'>.a - failure_demo.py:230: AssertionError + failure_demo.py:264: AssertionError ___________________ TestCustomAssertMsg.test_custom_repr ___________________ self = def test_custom_repr(self): + class JSON(object): a = 1 + def __repr__(self): return "This is JSON\n{\n 'foo': 'bar'\n}" + a = JSON() b = 2 > assert a.a == b, a @@ -596,7 +623,7 @@ get on the terminal - we are working on that):: E assert 1 == 2 E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a - failure_demo.py:240: AssertionError + failure_demo.py:278: AssertionError ============================= warnings summary ============================= None Metafunc.addcall is deprecated and scheduled to be removed in pytest 4.0. diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index c6df26108..180637ae9 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -54,10 +54,10 @@ Let's run this without supplying our new option:: def test_answer(cmdopt): if cmdopt == "type1": - print ("first") + print("first") elif cmdopt == "type2": - print ("second") - > assert 0 # to see what was printed + print("second") + > assert 0 # to see what was printed E assert 0 test_sample.py:6: AssertionError @@ -76,10 +76,10 @@ And now with supplying a command line option:: def test_answer(cmdopt): if cmdopt == "type1": - print ("first") + print("first") elif cmdopt == "type2": - print ("second") - > assert 0 # to see what was printed + print("second") + > assert 0 # to see what was printed E assert 0 test_sample.py:6: AssertionError @@ -241,7 +241,7 @@ Let's run our little function:: > checkconfig(42) E Failed: not configured: 42 - test_checkconfig.py:8: Failed + test_checkconfig.py:11: Failed 1 failed in 0.12 seconds If you only want to hide certain exceptions, you can set ``__tracebackhide__`` @@ -416,7 +416,7 @@ Now we can profile which test functions execute the slowest:: ========================= slowest 3 test durations ========================= 0.30s call test_some_are_slow.py::test_funcslow2 0.20s call test_some_are_slow.py::test_funcslow1 - 0.11s call test_some_are_slow.py::test_funcfast + 0.10s call test_some_are_slow.py::test_funcfast ========================= 3 passed in 0.12 seconds ========================= incremental testing - test steps @@ -494,7 +494,7 @@ If we run this:: > assert 0 E assert 0 - test_step.py:9: AssertionError + test_step.py:11: AssertionError ========================= short test summary info ========================== XFAIL test_step.py::TestUserHandling::()::test_deletion reason: previous test failed (test_modification) @@ -587,7 +587,7 @@ We can run this:: > assert 0 E assert 0 - test_step.py:9: AssertionError + test_step.py:11: AssertionError _________________________________ test_a1 __________________________________ db = @@ -693,7 +693,7 @@ and run them:: > assert 0 E assert 0 - test_module.py:4: AssertionError + test_module.py:6: AssertionError ========================= 2 failed in 0.12 seconds ========================= you will have a "failures" file which contains the failing test ids:: @@ -786,7 +786,7 @@ and run it:: > assert 0 E assert 0 - test_module.py:6: AssertionError + test_module.py:7: AssertionError ================================= FAILURES ================================= _____________________________ test_call_fails ______________________________ @@ -796,14 +796,14 @@ and run it:: > assert 0 E assert 0 - test_module.py:12: AssertionError + test_module.py:15: AssertionError ________________________________ test_fail2 ________________________________ def test_fail2(): > assert 0 E assert 0 - test_module.py:15: AssertionError + test_module.py:19: AssertionError ==================== 2 failed, 1 error in 0.12 seconds ===================== You'll see that the fixture finalizers could use the precise reporting diff --git a/doc/en/index.rst b/doc/en/index.rst index 1ab41cbcd..6a382e571 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -40,7 +40,7 @@ To execute it:: E assert 4 == 5 E + where 4 = inc(3) - test_sample.py:5: AssertionError + test_sample.py:6: AssertionError ========================= 1 failed in 0.12 seconds ========================= Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. diff --git a/pyproject.toml b/pyproject.toml index 88571e208..ffce583f6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,6 @@ [tool.towncrier] package = "pytest" +package_dir = "src" filename = "CHANGELOG.rst" directory = "changelog/" template = "changelog/_template.rst"