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 *"] + )