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

Fix issue pytest_plugins as string was marking wrong modules for rewrite #1891

Merged
merged 2 commits into from
Aug 31, 2016

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Aug 31, 2016

Unfortunately due to a small bug on how the pytest_plugins variable was handled, we are currently rewriting assertions in much more modules than we initially thought:

pytest_plugins = 'setuptools.tests.fixtures'

The code that handles that in config.py was expecting pytest_plugins to be a list[str] only:

    def consider_module(self, mod):
        plugins = getattr(mod, 'pytest_plugins', [])
        self.rewrite_hook.mark_rewrite(*plugins)
        self._import_plugin_specs(plugins)

So it would end up marking each letter in "setuptools.tests.fixtures" as an individual module, which basically means rewriting every module which starts with s, e, t, u and so on.

Coupling that with some advanced bootstrapping done in setuptools between each test and a lot of tests were failing quite catastrophically.

Initially I started the investigation for this issue by implementing the optional find_spec API, but it was only hiding the real bug so I decided to not touch that for now.

Beside testing locally, I opened pypa/setuptools#768 to make sure the fix worked. 😅

This fixes #1888

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 93.088% when pulling c8a366e on nicoddemus:find-spec-rewrite-hook into 82218e4 on pytest-dev:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 93.088% when pulling edf8283 on nicoddemus:find-spec-rewrite-hook into 82218e4 on pytest-dev:master.

@The-Compiler The-Compiler merged commit 67ba8aa into pytest-dev:master Aug 31, 2016
@The-Compiler
Copy link
Member

That must've been a tricky one - thanks!

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.

AssertionRewritingHook object has no attribute find_spec
4 participants