From 5e41c64b24ae9ee72f1b920257cb23cfeb8c7ff6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 24 Feb 2020 23:07:46 +0100 Subject: [PATCH] tests: check result with `test_510` Note that the output changed with 9e262038c8, so the test should likely be fixed. Ref: https://github.com/pytest-dev/pytest/issues/519 (- haven't looked into what the issue is about). Example script was added in c081c5ee2, changed in ea906056f, currently outputs: Previous output: ``` ['============================= test session starts ==============================', 'platform linux -- Python 3.8.1, pytest-5.3.5.dev567+gfba7d992a.d20200224, py-1.8.2.dev3+g2b6bd292, pluggy-0.13.1', 'rootdir: ~', 'collected 8 items', '', 'issue_519.py ........E [100%]', '', '==================================== ERRORS ====================================', '_________________ ERROR at teardown of test_two[arg1v2-arg2v2] _________________', '', ' @pytest.fixture(scope="session")', ' def checked_order():', ' order = []', ' ', ' yield order', ' pprint.pprint(order)', '> assert order == [', ' ("testing/example_scripts/issue_519.py", "fix1", "arg1v1"),', ' ("test_one[arg1v1-arg2v1]", "fix2", "arg2v1"),', ' ("test_two[arg1v1-arg2v1]", "fix2", "arg2v1"),', ' ("test_one[arg1v1-arg2v2]", "fix2", "arg2v2"),', ' ("test_two[arg1v1-arg2v2]", "fix2", "arg2v2"),', ' ("testing/example_scripts/issue_519.py", "fix1", "arg1v2"),', ' ("test_one[arg1v2-arg2v1]", "fix2", "arg2v1"),', ' ("test_two[arg1v2-arg2v1]", "fix2", "arg2v1"),', ' ("test_one[arg1v2-arg2v2]", "fix2", "arg2v2"),', ' ("test_two[arg1v2-arg2v2]", "fix2", "arg2v2"),', ' ]', "E AssertionError: assert [('issue_519....arg1v2'), ...] == [('testing/ex...arg1v2'), ...]", 'E At index 0 diff:', "E ('issue_519.py', 'fix1', 'arg1v1') !=", "E ('testing/example_scripts/issue_519.py', 'fix1', 'arg1v1')", 'E Use -v to get the full diff', '', "issue_519.py:20: AssertionError: assert [('issue_519....arg1v2'), ...] == [('testing/ex...arg1v2'), ...]...", '--------------------------- Captured stdout teardown ---------------------------', "[('issue_519.py', 'fix1', 'arg1v1'),", " ('test_one[arg1v1-arg2v1]', 'fix2', 'arg2v1'),", " ('test_two[arg1v1-arg2v1]', 'fix2', 'arg2v1'),", " ('test_one[arg1v1-arg2v2]', 'fix2', 'arg2v2'),", " ('test_two[arg1v1-arg2v2]', 'fix2', 'arg2v2'),", " ('issue_519.py', 'fix1', 'arg1v2'),", " ('test_one[arg1v2-arg2v1]', 'fix2', 'arg2v1'),", " ('test_two[arg1v2-arg2v1]', 'fix2', 'arg2v1'),", " ('test_one[arg1v2-arg2v2]', 'fix2', 'arg2v2'),", " ('test_two[arg1v2-arg2v2]', 'fix2', 'arg2v2')]", ``` --- testing/examples/test_issue519.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/testing/examples/test_issue519.py b/testing/examples/test_issue519.py index e83f18fdc93..c41e2b18591 100644 --- a/testing/examples/test_issue519.py +++ b/testing/examples/test_issue519.py @@ -1,3 +1,20 @@ +"""Test for https://github.com/pytest-dev/pytest/issues/519.""" + + def test_510(testdir): testdir.copy_example("issue_519.py") - testdir.runpytest("issue_519.py") + result = testdir.runpytest("issue_519.py") + result.stdout.fnmatch_lines( + [ + "collected 0 items / 1 error", + "", + "*= ERRORS =*", + "*_ ERROR collecting issue_519.py _*", + 'In function "test_one":', + 'Parameter "arg1" should be declared explicitly via indirect or in function itself', + "*= short test summary info =*", + "ERROR issue_519.py", + "*! Interrupted: 1 error during collection !*", + "*= 1 error in *=", + ] + )