-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
showing pytest warnings summary by default. #1672
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice, but also I think we should remove |
||
"(p)passed, (P)passed with output, (a)all except pP.") | ||
"(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).") | ||
|
@@ -66,6 +71,10 @@ def getreportopt(config): | |
elif setting == "xfailed": | ||
reportopts += "x" | ||
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': | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -519,7 +519,7 @@ def test_hello(fix): | |
""") | ||
result = testdir.runpytest() | ||
assert result.parseoutcomes()["pytest-warnings"] > 0 | ||
assert "hello" not in result.stdout.str() | ||
assert "hello" in result.stdout.str() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this code needs to revert the change in the assertion and pass |
||
|
||
result = testdir.runpytest("-rw") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense for this call to no longer pass anything, and the warning should appear in the output normally. |
||
result.stdout.fnmatch_lines(""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Whitelisted pytest warnings" seems confusing - it sounds like some warnings are on a whitelist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will rephrase this once I get to a place with a stable internet connection :)