Permalink
Browse files

Fix pytest when pyfakefs + future is installed

`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
  • Loading branch information...
asottile authored and mrbean-bremen committed Oct 10, 2018
1 parent 1886f92 commit 51781b95b629a31107d16a52b0ea184306fe6163
Showing with 3 additions and 2 deletions.
  1. +3 −2 pyfakefs/pytest_plugin.py
@@ -10,15 +10,16 @@ def my_fakefs_test(fs):
"""
import linecache
import sys
import py
import pytest
from pyfakefs.fake_filesystem_unittest import Patcher
try:
if sys.version_info >= (3,):
import builtins
except ImportError:
else:
import __builtin__ as builtins
Patcher.SKIPMODULES.add(py) # Ignore pytest components when faking filesystem

0 comments on commit 51781b9

Please sign in to comment.