From cee578e32786986cb79495a2ea0e5c5e4eb425ce Mon Sep 17 00:00:00 2001 From: fbjorn Date: Sun, 5 Mar 2017 22:44:13 +0300 Subject: [PATCH] Fix trailing whitespace in terminal output --- AUTHORS | 1 + CHANGELOG.rst | 6 ++++-- _pytest/terminal.py | 4 ++-- testing/test_config.py | 2 +- testing/test_terminal.py | 9 +++++++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index 821bd2a6d..ce19f1f21 100644 --- a/AUTHORS +++ b/AUTHORS @@ -43,6 +43,7 @@ Dave Hunt David Díaz-Barquero David Mohr David Vierra +Denis Kirisov Diego Russo Dmitry Dygalo Duncan Betts diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 216891484..cf3df9c87 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -27,8 +27,8 @@ * Skipping plugin now also works with test items generated by custom collectors (`#2231`_). Thanks to `@vidartf`_. - -* + +* Fix trailing whitespace in console output if no .ini file presented (`#2281`_). Thanks `@fbjorn`_ for the PR. * Conditionless ``xfail`` markers no longer rely on the underlying test item being an instance of ``PyobjMixin``, and can therefore apply to tests not @@ -44,6 +44,7 @@ .. _@vidartf: https://github.com/vidartf .. _@kkoukiou: https://github.com/KKoukiou .. _@omerhadari: https://github.com/omerhadari +.. _@fbjorn: https://github.com/fbjorn .. _#2248: https://github.com/pytest-dev/pytest/issues/2248 .. _#2137: https://github.com/pytest-dev/pytest/issues/2137 @@ -51,6 +52,7 @@ .. _#2231: https://github.com/pytest-dev/pytest/issues/2231 .. _#2234: https://github.com/pytest-dev/pytest/issues/2234 .. _#2238: https://github.com/pytest-dev/pytest/issues/2238 +.. _#2281: https://github.com/pytest-dev/pytest/issues/2281 .. _PEP-479: https://www.python.org/dev/peps/pep-0479/ diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 16bf75733..79e065329 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -295,8 +295,8 @@ class TerminalReporter: def pytest_report_header(self, config): inifile = "" if config.inifile: - inifile = config.rootdir.bestrelpath(config.inifile) - lines = ["rootdir: %s, inifile: %s" %(config.rootdir, inifile)] + inifile = " " + config.rootdir.bestrelpath(config.inifile) + lines = ["rootdir: %s, inifile:%s" % (config.rootdir, inifile)] plugininfo = config.pluginmanager.list_plugin_distinfo() if plugininfo: diff --git a/testing/test_config.py b/testing/test_config.py index 3ce51d639..b6ccd7085 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -519,7 +519,7 @@ def test_consider_args_after_options_for_rootdir_and_inifile(testdir, args): args[i] = d2 with root.as_cwd(): result = testdir.runpytest(*args) - result.stdout.fnmatch_lines(['*rootdir: *myroot, inifile: ']) + result.stdout.fnmatch_lines(['*rootdir: *myroot, inifile:']) @pytest.mark.skipif("sys.platform == 'win32'") diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 3efd7b1f9..0f919b5ed 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -906,3 +906,12 @@ def test_summary_stats(exp_line, exp_color, stats_arg): print("Actually got: \"%s\"; with color \"%s\"" % (line, color)) assert line == exp_line assert color == exp_color + + +def test_no_trailing_whitespace_after_inifile_word(testdir): + result = testdir.runpytest('') + assert 'inifile:\n' in result.stdout.str() + + testdir.makeini('[pytest]') + result = testdir.runpytest('') + assert 'inifile: tox.ini\n' in result.stdout.str()