Skip to content

Fix false-positive assert rewrite warnings when using 'pytest_plugins'#2110

Merged
RonnyPfannschmidt merged 1 commit intopytest-dev:masterfrom
nicoddemus:rewrite-warning-pytest-plugins
Dec 1, 2016
Merged

Fix false-positive assert rewrite warnings when using 'pytest_plugins'#2110
RonnyPfannschmidt merged 1 commit intopytest-dev:masterfrom
nicoddemus:rewrite-warning-pytest-plugins

Conversation

@nicoddemus
Copy link
Copy Markdown
Member

@nicoddemus nicoddemus commented Dec 1, 2016

pytest would emit false-positive warnings about assertion-rewrite when a module appears multiple times in plugins which depend on other plugins using the pytest_plugins mechanism.

Here's the output of the test added by this PR on master:

self = <test_assertrewrite.TestRewriteOnImport instance at 0x000000000430A208>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch instance at 0x000000000401FF88>

    def test_rewrite_warning_using_pytest_plugins(self, testdir, monkeypatch):
        testdir.makepyfile(**{
            'conftest.py': "pytest_plugins = ['core', 'gui', 'sci']",
            'core.py': "",
            'gui.py': "pytest_plugins = ['core', 'sci']",
            'sci.py': "pytest_plugins = ['core']",
            'test_rewrite_warning_pytest_plugins.py': "def test(): pass",
        })
        testdir.chdir()
        result = testdir.runpytest_subprocess()
>       result.stdout.fnmatch_lines(['*= 1 passed in *=*'])
E       Failed: nomatch: '*= 1 passed in *=*'
E           and: u'============================= test session starts ============================='
E           and: u'platform win32 -- Python 2.7.9, pytest-3.0.5.dev0, py-1.4.31, pluggy-0.4.0'
E           and: u'plugins: hypothesis-3.6.0'
E           and: u'collected 1 items'
E           and: u''
E           and: u'test_rewrite_warning_pytest_plugins.py .'
E           and: u''
E           and: u'=========================== pytest-warning summary ============================'
E           and: u'WP1 None Modules are already imported so can not be re-written: core'
E           and: u'================= 1 passed, 1 pytest-warnings in 0.01 seconds ================='
E       remains unmatched: '*= 1 passed in *=*'

pytest would emit false positive warnings about assertion-rewrite when a
module appears multiple times in plugins which depend
on other plugins using the 'pytest_plugins' mechanism
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 92.825% when pulling bc0f7e6 on nicoddemus:rewrite-warning-pytest-plugins into 9ed3d76 on pytest-dev:master.

@RonnyPfannschmidt
Copy link
Copy Markdown
Member

\o/ that one was the blocker i found in our production env that i couldn't identify, awesome :) now i can update to pytest 3.0.x for that repo

@RonnyPfannschmidt RonnyPfannschmidt merged commit 64193ad into pytest-dev:master Dec 1, 2016
@nicoddemus nicoddemus deleted the rewrite-warning-pytest-plugins branch December 1, 2016 19:50
@nicoddemus
Copy link
Copy Markdown
Member Author

Cool! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants