Skip to content

Commit

Permalink
Fix pytest when pyfakefs + future is installed
Browse files Browse the repository at this point in the history
`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 11, 2018
1 parent 1886f92 commit 51781b9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyfakefs/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51781b9

Please sign in to comment.