From 2f589a9769e12e71253624372e7eeb7076b7549b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 23 Oct 2019 00:00:15 +0200 Subject: [PATCH] pytester: runpytest_inprocess: use splitlines() This avoids having a trailing empty lines always. --- src/_pytest/pytester.py | 4 +++- testing/test_config.py | 2 +- testing/test_runner.py | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/_pytest/pytester.py b/src/_pytest/pytester.py index 2ce3701c0..2a9ef12b8 100644 --- a/src/_pytest/pytester.py +++ b/src/_pytest/pytester.py @@ -878,7 +878,9 @@ class Testdir: sys.stdout.write(out) sys.stderr.write(err) - res = RunResult(reprec.ret, out.split("\n"), err.split("\n"), time.time() - now) + res = RunResult( + reprec.ret, out.splitlines(), err.splitlines(), time.time() - now + ) res.reprec = reprec return res diff --git a/testing/test_config.py b/testing/test_config.py index 0264b029d..d4d624348 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -1291,7 +1291,7 @@ def test_config_blocked_default_plugins(testdir, plugin): if plugin != "terminal": result.stdout.fnmatch_lines(["* 1 failed in *"]) else: - assert result.stdout.lines == [""] + assert result.stdout.lines == [] class TestSetupCfg: diff --git a/testing/test_runner.py b/testing/test_runner.py index d2ce5d0bc..86e9bddff 100644 --- a/testing/test_runner.py +++ b/testing/test_runner.py @@ -597,7 +597,7 @@ def test_pytest_exit_returncode(testdir): result = testdir.runpytest() result.stdout.fnmatch_lines(["*! *Exit: some exit msg !*"]) - assert _strip_resource_warnings(result.stderr.lines) == [""] + assert _strip_resource_warnings(result.stderr.lines) == [] assert result.ret == 99 # It prints to stderr also in case of exit during pytest_sessionstart. @@ -612,8 +612,7 @@ def test_pytest_exit_returncode(testdir): result = testdir.runpytest() result.stdout.fnmatch_lines(["*! *Exit: during_sessionstart !*"]) assert _strip_resource_warnings(result.stderr.lines) == [ - "Exit: during_sessionstart", - "", + "Exit: during_sessionstart" ] assert result.ret == 98