diff --git a/AUTHORS b/AUTHORS index 67111393ce0..d43c4aa74ff 100644 --- a/AUTHORS +++ b/AUTHORS @@ -9,6 +9,7 @@ Alexei Kozlenok Anatoly Bubenkoff Andreas Zeidler Andy Freeland +Andrzej Ostrowski Anthon van der Neut Antony Lee Armin Rigo diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6bed6ed4274..cfd77cb0c97 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -160,6 +160,10 @@ time or change existing behaviors in order to make them less surprising/more use parametrize. Thanks `@palaviv`_ for the complete PR (`#1474`_). +* Now pytest warnings summary is shown up by default. Added a new flag + ``--disable-pytest-warnings`` to explicitly disable the warnings summary. + This change resolves the (`#1668`_). + * Make ImportError during collection more explicit by reminding the user to check the name of the test module/package(s) (`#1426`_). Thanks `@omarkohl`_ for the complete PR (`#1520`_). @@ -216,6 +220,8 @@ time or change existing behaviors in order to make them less surprising/more use * Fix internal error issue when the ``method`` argument is missing for ``teardown_method()`` (`#1605`_). +* Renamed the pytest ``pdb`` module (plugin) into ``debugging``. + * Fix exception visualization in case the current working directory (CWD) gets deleted during testing (`#1235`_). Thanks `@bukzor`_ for reporting. PR by `@marscher`_. @@ -268,6 +274,7 @@ time or change existing behaviors in order to make them less surprising/more use .. _#1618: https://github.com/pytest-dev/pytest/issues/1618 .. _#1619: https://github.com/pytest-dev/pytest/issues/1619 .. _#1626: https://github.com/pytest-dev/pytest/pull/1626 +.. _#1668: https://github.com/pytest-dev/pytest/issues/1668 .. _#1627: https://github.com/pytest-dev/pytest/pull/1627 .. _#1628: https://github.com/pytest-dev/pytest/pull/1628 .. _#1629: https://github.com/pytest-dev/pytest/issues/1629 diff --git a/_pytest/terminal.py b/_pytest/terminal.py index b88a19e139e..7db0fda7473 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -20,10 +20,15 @@ def pytest_addoption(parser): group._addoption('-q', '--quiet', action="count", dest="quiet", default=0, help="decrease verbosity."), group._addoption('-r', - action="store", dest="reportchars", default=None, metavar="chars", + action="store", dest="reportchars", default='', metavar="chars", help="show extra test summary info as specified by chars (f)ailed, " - "(E)error, (s)skipped, (x)failed, (X)passed (w)pytest-warnings " - "(p)passed, (P)passed with output, (a)all except pP.") + "(E)error, (s)skipped, (x)failed, (X)passed, " + "(p)passed, (P)passed with output, (a)all except pP. " + "The pytest warnings are displayed at all times except when " + "--disable-pytest-warnings is set") + group._addoption('--disable-pytest-warnings', default=False, + dest='disablepytestwarnings', action='store_true', + help='disable warnings summary, overrides -r w flag') group._addoption('-l', '--showlocals', action="store_true", dest="showlocals", default=False, help="show locals in tracebacks (disabled by default).") @@ -52,6 +57,10 @@ def mywriter(tags, args): def getreportopt(config): reportopts = "" reportchars = config.option.reportchars + if not config.option.disablepytestwarnings and 'w' not in reportchars: + reportchars += 'w' + elif config.option.disablepytestwarnings and 'w' in reportchars: + reportchars = reportchars.replace('w', '') if reportchars: for char in reportchars: if char not in reportopts and char != 'a': diff --git a/testing/test_config.py b/testing/test_config.py index bb686c3b058..288b6670327 100644 --- a/testing/test_config.py +++ b/testing/test_config.py @@ -539,11 +539,11 @@ def fix(request): def test_hello(fix): pass """) - result = testdir.runpytest() + result = testdir.runpytest("--disable-pytest-warnings") assert result.parseoutcomes()["pytest-warnings"] > 0 assert "hello" not in result.stdout.str() - result = testdir.runpytest("-rw") + result = testdir.runpytest() result.stdout.fnmatch_lines(""" ===*pytest-warning summary*=== *WT1*test_warn_on_test_item*:5*hello* diff --git a/testing/test_terminal.py b/testing/test_terminal.py index 5d055e416aa..51e62f3a0fb 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -590,13 +590,23 @@ def test_getreportopt(): class config: class option: reportchars = "" + disablepytestwarnings = True config.option.reportchars = "sf" assert getreportopt(config) == "sf" - config.option.reportchars = "sfx" + config.option.reportchars = "sfxw" assert getreportopt(config) == "sfx" + config.option.reportchars = "sfx" + config.option.disablepytestwarnings = False + assert getreportopt(config) == "sfxw" + + config.option.reportchars = "sfxw" + config.option.disablepytestwarnings = False + assert getreportopt(config) == "sfxw" + + def test_terminalreporter_reportopt_addopts(testdir): testdir.makeini("[pytest]\naddopts=-rs") testdir.makepyfile("""