Skip to content

Commit 1fb09d9

Browse files
authored
Merge pull request #1726 from nicoddemus/warnings-displayed-by-default
Warnings displayed by default
2 parents 6e9ee2b + 1266ebe commit 1fb09d9

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Alexei Kozlenok
99
Anatoly Bubenkoff
1010
Andreas Zeidler
1111
Andy Freeland
12+
Andrzej Ostrowski
1213
Anthon van der Neut
1314
Antony Lee
1415
Armin Rigo

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ time or change existing behaviors in order to make them less surprising/more use
160160
parametrize.
161161
Thanks `@palaviv`_ for the complete PR (`#1474`_).
162162

163+
* Now pytest warnings summary is shown up by default. Added a new flag
164+
``--disable-pytest-warnings`` to explicitly disable the warnings summary.
165+
This change resolves the (`#1668`_).
166+
163167
* Make ImportError during collection more explicit by reminding
164168
the user to check the name of the test module/package(s) (`#1426`_).
165169
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
216220
* Fix internal error issue when the ``method`` argument is missing for
217221
``teardown_method()`` (`#1605`_).
218222

223+
* Renamed the pytest ``pdb`` module (plugin) into ``debugging``.
224+
219225
* Fix exception visualization in case the current working directory (CWD) gets
220226
deleted during testing (`#1235`_). Thanks `@bukzor`_ for reporting. PR by
221227
`@marscher`_.
@@ -268,6 +274,7 @@ time or change existing behaviors in order to make them less surprising/more use
268274
.. _#1618: https://github.com/pytest-dev/pytest/issues/1618
269275
.. _#1619: https://github.com/pytest-dev/pytest/issues/1619
270276
.. _#1626: https://github.com/pytest-dev/pytest/pull/1626
277+
.. _#1668: https://github.com/pytest-dev/pytest/issues/1668
271278
.. _#1627: https://github.com/pytest-dev/pytest/pull/1627
272279
.. _#1628: https://github.com/pytest-dev/pytest/pull/1628
273280
.. _#1629: https://github.com/pytest-dev/pytest/issues/1629

_pytest/terminal.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,15 @@ def pytest_addoption(parser):
2020
group._addoption('-q', '--quiet', action="count",
2121
dest="quiet", default=0, help="decrease verbosity."),
2222
group._addoption('-r',
23-
action="store", dest="reportchars", default=None, metavar="chars",
23+
action="store", dest="reportchars", default='', metavar="chars",
2424
help="show extra test summary info as specified by chars (f)ailed, "
25-
"(E)error, (s)skipped, (x)failed, (X)passed (w)pytest-warnings "
26-
"(p)passed, (P)passed with output, (a)all except pP.")
25+
"(E)error, (s)skipped, (x)failed, (X)passed, "
26+
"(p)passed, (P)passed with output, (a)all except pP. "
27+
"The pytest warnings are displayed at all times except when "
28+
"--disable-pytest-warnings is set")
29+
group._addoption('--disable-pytest-warnings', default=False,
30+
dest='disablepytestwarnings', action='store_true',
31+
help='disable warnings summary, overrides -r w flag')
2732
group._addoption('-l', '--showlocals',
2833
action="store_true", dest="showlocals", default=False,
2934
help="show locals in tracebacks (disabled by default).")
@@ -52,6 +57,10 @@ def mywriter(tags, args):
5257
def getreportopt(config):
5358
reportopts = ""
5459
reportchars = config.option.reportchars
60+
if not config.option.disablepytestwarnings and 'w' not in reportchars:
61+
reportchars += 'w'
62+
elif config.option.disablepytestwarnings and 'w' in reportchars:
63+
reportchars = reportchars.replace('w', '')
5564
if reportchars:
5665
for char in reportchars:
5766
if char not in reportopts and char != 'a':

testing/test_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,11 @@ def fix(request):
539539
def test_hello(fix):
540540
pass
541541
""")
542-
result = testdir.runpytest()
542+
result = testdir.runpytest("--disable-pytest-warnings")
543543
assert result.parseoutcomes()["pytest-warnings"] > 0
544544
assert "hello" not in result.stdout.str()
545545

546-
result = testdir.runpytest("-rw")
546+
result = testdir.runpytest()
547547
result.stdout.fnmatch_lines("""
548548
===*pytest-warning summary*===
549549
*WT1*test_warn_on_test_item*:5*hello*

testing/test_terminal.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,23 @@ def test_getreportopt():
590590
class config:
591591
class option:
592592
reportchars = ""
593+
disablepytestwarnings = True
593594

594595
config.option.reportchars = "sf"
595596
assert getreportopt(config) == "sf"
596597

597-
config.option.reportchars = "sfx"
598+
config.option.reportchars = "sfxw"
598599
assert getreportopt(config) == "sfx"
599600

601+
config.option.reportchars = "sfx"
602+
config.option.disablepytestwarnings = False
603+
assert getreportopt(config) == "sfxw"
604+
605+
config.option.reportchars = "sfxw"
606+
config.option.disablepytestwarnings = False
607+
assert getreportopt(config) == "sfxw"
608+
609+
600610
def test_terminalreporter_reportopt_addopts(testdir):
601611
testdir.makeini("[pytest]\naddopts=-rs")
602612
testdir.makepyfile("""

0 commit comments

Comments
 (0)