Skip to content

Fix pytest when pyfakefs + future is installed#441

Merged
mrbean-bremen merged 1 commit intopytest-dev:masterfrom
asottile:fix_when_future_installed
Oct 11, 2018
Merged

Fix pytest when pyfakefs + future is installed#441
mrbean-bremen merged 1 commit intopytest-dev:masterfrom
asottile:fix_when_future_installed

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