summaryrefslogtreecommitdiff
path: root/testing/test_terminal.py
diff options
context:
space:
mode:
authorpiotrhm <helm.piotr@gmail.com>2020-05-25 19:29:18 +0200
committerBruno Oliveira <nicoddemus@gmail.com>2020-06-08 22:26:14 -0300
commit51fb11c1d1436fb438cfe4d014b34c46fc342b70 (patch)
tree9d9139c679cc3c426730798bd9832e6ac3ba2f89 /testing/test_terminal.py
parent0b70300ba4c00f2fdab1415b33ac6b035418e648 (diff)
downloadpytest-51fb11c1d1436fb438cfe4d014b34c46fc342b70.tar.gz
Added tests
Diffstat (limited to 'testing/test_terminal.py')
-rw-r--r--testing/test_terminal.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/testing/test_terminal.py b/testing/test_terminal.py
index e8402079b..8b8c246ba 100644
--- a/testing/test_terminal.py
+++ b/testing/test_terminal.py
@@ -698,6 +698,29 @@ class TestTerminalFunctional:
if request.config.pluginmanager.list_plugin_distinfo():
result.stdout.fnmatch_lines(["plugins: *"])
+ def test_no_header_trailer_info(self, testdir, request):
+ testdir.monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD")
+ testdir.makepyfile(
+ """
+ def test_passes():
+ pass
+ """
+ )
+ result = testdir.runpytest("--no-header")
+ verinfo = ".".join(map(str, sys.version_info[:3]))
+ result.stdout.no_fnmatch_line(
+ "platform %s -- Python %s*pytest-%s*py-%s*pluggy-%s"
+ % (
+ sys.platform,
+ verinfo,
+ pytest.__version__,
+ py.__version__,
+ pluggy.__version__,
+ )
+ )
+ if request.config.pluginmanager.list_plugin_distinfo():
+ result.stdout.no_fnmatch_line("plugins: *")
+
def test_header(self, testdir):
testdir.tmpdir.join("tests").ensure_dir()
testdir.tmpdir.join("gui").ensure_dir()
@@ -727,6 +750,36 @@ class TestTerminalFunctional:
result = testdir.runpytest("tests")
result.stdout.fnmatch_lines(["rootdir: *test_header0, configfile: tox.ini"])
+ def test_no_header(self, testdir):
+ testdir.tmpdir.join("tests").ensure_dir()
+ testdir.tmpdir.join("gui").ensure_dir()
+
+ # with testpaths option, and not passing anything in the command-line
+ testdir.makeini(
+ """
+ [pytest]
+ testpaths = tests gui
+ """
+ )
+ result = testdir.runpytest("--no-header")
+ result.stdout.no_fnmatch_line(
+ "rootdir: *test_header0, inifile: tox.ini, testpaths: tests, gui"
+ )
+
+ # with testpaths option, passing directory in command-line: do not show testpaths then
+ result = testdir.runpytest("tests", "--no-header")
+ result.stdout.no_fnmatch_line("rootdir: *test_header0, inifile: tox.ini")
+
+ def test_no_summary(self, testdir):
+ p1 = testdir.makepyfile(
+ """
+ def test_no_summary():
+ assert false
+ """
+ )
+ result = testdir.runpytest("--no-summary")
+ result.stdout.no_fnmatch_line("*= FAILURES =*")
+
def test_showlocals(self, testdir):
p1 = testdir.makepyfile(
"""
@@ -1483,6 +1536,21 @@ def test_terminal_summary_warnings_header_once(testdir):
assert stdout.count("=== warnings summary ") == 1
+@pytest.mark.filterwarnings("default")
+def test_terminal_no_summary_warnings_header_once(testdir):
+ testdir.makepyfile(
+ """
+ def test_failure():
+ import warnings
+ warnings.warn("warning_from_" + "test")
+ assert 0
+ """
+ )
+ result = testdir.runpytest("--no-summary")
+ result.stdout.no_fnmatch_line("*= warnings summary =*")
+ result.stdout.no_fnmatch_line("*= short test summary info =*")
+
+
@pytest.fixture(scope="session")
def tr() -> TerminalReporter:
config = _pytest.config._prepareconfig()
@@ -2130,6 +2198,12 @@ def test_collecterror(testdir):
)
+def test_no_summary_collecterror(testdir):
+ p1 = testdir.makepyfile("raise SyntaxError()")
+ result = testdir.runpytest("-ra", "--no-summary", str(p1))
+ result.stdout.no_fnmatch_line("*= ERRORS =*")
+
+
def test_via_exec(testdir: Testdir) -> None:
p1 = testdir.makepyfile("exec('def test_via_exec(): pass')")
result = testdir.runpytest(str(p1), "-vv")