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 pytest when pyfakefs + future is installed #441

Merged
merged 1 commit into from
Oct 11, 2018
Merged

Fix pytest when pyfakefs + future is installed #441

merged 1 commit into from
Oct 11, 2018

Conversation

asottile
Copy link
Member

python-future is notorious for breaking modules which use try: / except:
to import modules based on version. In this case, pyfakefs imported the
backported builtins module which changes the semantics of the open()
function. pyfakefs then monkeypatches linecache which breaks any module
which attempts to use linecache (in this case pytest).

The downstream issue is pytest-dev/pytest#4074

`python-future` is notorious for breaking modules which use `try:` / `except:`
to import modules based on version.  In this case, `pyfakefs` imported the
backported `builtins` module which changes the semantics of the `open()`
function.  `pyfakefs` then monkeypatches `linecache` which breaks any module
which attempts to use `linecache` (in this case `pytest`).

The downstream issue is pytest-dev/pytest#4074
@mrbean-bremen
Copy link
Member

Thanks - wouldn't have expected that! Is this something that could cause problems in other places? We use try/except for import in other places in pyfakefs, too.

@mrbean-bremen mrbean-bremen merged commit 51781b9 into pytest-dev:master Oct 11, 2018
@asottile asottile deleted the fix_when_future_installed branch October 11, 2018 04:11
@asottile
Copy link
Member Author

I did an audit of the other imports while implementing this and you should be good (they were (essentially) all for pathlib / scandir which future doesn't "backport")

@mrbean-bremen
Copy link
Member

Ok, thank you!

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.

2 participants