Skip to content
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

Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types' #5452

Merged
merged 1 commit into from Jun 16, 2019

Conversation

Projects
None yet
4 participants
@nicoddemus
Copy link
Member

commented Jun 15, 2019

When we configure warnings as errors, users see error messages like this:

        def test():
    >       warnings.warn(pytest.PytestWarning("some warning"))
    E       _pytest.warning_types.PytestWarning: some warning

This is a problem because suggests the user should use _pytest.warning_types.PytestWarning to configure
their warning filters, which is not nice.

This commit changes the message to:

        def test():
    >       warnings.warn(pytest.PytestWarning("some warning"))
    E       pytest.PytestWarning: some warning

I noticed we already do this for some exceptions, marking them as from the builtins module to make their tracebacks shorter.

Make pytest warnings show as from 'pytest' module instead of '_pytest…
….warning_types'

When we configure warnings as errors, users see error messages like this:

        def test():
    >       warnings.warn(pytest.PytestWarning("some warning"))
    E       _pytest.warning_types.PytestWarning: some warning

This is a problem because suggests the user should use `_pytest.warning_types.PytestWarning` to configure
their warning filters, which is not nice.

This commit changes the message to:

        def test():
    >       warnings.warn(pytest.PytestWarning("some warning"))
    E       pytest.PytestWarning: some warning

@nicoddemus nicoddemus force-pushed the nicoddemus:warnings-pytest-mod branch from 6816a11 to 43e8576 Jun 15, 2019

@codecov

This comment has been minimized.

Copy link

commented Jun 15, 2019

Codecov Report

Merging #5452 into master will increase coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5452      +/-   ##
==========================================
+ Coverage   95.92%   95.99%   +0.07%     
==========================================
  Files         114      115       +1     
  Lines       25498    25517      +19     
  Branches     2479     2480       +1     
==========================================
+ Hits        24458    24496      +38     
+ Misses        728      715      -13     
+ Partials      312      306       -6
Impacted Files Coverage Δ
src/_pytest/warning_types.py 100% <100%> (ø) ⬆️
testing/test_warning_types.py 100% <100%> (ø)
src/_pytest/assertion/rewrite.py 93.49% <0%> (+0.54%) ⬆️
src/_pytest/doctest.py 95.43% <0%> (+0.76%) ⬆️
testing/test_pdb.py 99% <0%> (+0.99%) ⬆️
src/_pytest/pathlib.py 88.95% <0%> (+1.16%) ⬆️
src/_pytest/assertion/util.py 93.41% <0%> (+2.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 240828d...43e8576. Read the comment docs.

@asottile
Copy link
Member

left a comment

@nicoddemus

This comment has been minimized.

Copy link
Member Author

commented Jun 16, 2019

(that's the stuff of nightmares right there: #5452 (review))

@nicoddemus nicoddemus merged commit 87fc5a5 into pytest-dev:master Jun 16, 2019

5 checks passed

WIP Ready for review
Details
codecov/patch 100% of diff hit (target 95.92%)
Details
codecov/project 95.99% (+0.07%) compared to 240828d
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
pytest-CI #20190615.7 succeeded
Details

@nicoddemus nicoddemus deleted the nicoddemus:warnings-pytest-mod branch Jun 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.