From 40758e86ca9d287069df45c732d586b4905613f6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 26 Jan 2020 16:41:17 +0100 Subject: [PATCH] tests: add test_via_exec Via https://github.com/pytest-dev/pytest/issues/6574. --- testing/test_terminal.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 09c9d5485..f284ad577 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -13,6 +13,7 @@ import py import pytest from _pytest.main import ExitCode +from _pytest.pytester import Testdir from _pytest.reports import BaseReport from _pytest.terminal import _folded_skips from _pytest.terminal import _get_line_with_reprcrash_message @@ -1923,3 +1924,11 @@ def test_collecterror(testdir): "*= 1 error in *", ] ) + + +def test_via_exec(testdir: Testdir) -> None: + p1 = testdir.makepyfile("exec('def test_via_exec(): pass')") + result = testdir.runpytest(str(p1), "-vv") + result.stdout.fnmatch_lines( + ["test_via_exec.py::test_via_exec <- PASSED*", "*= 1 passed in *"] + )