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

fake_filesystem_unittest.py uses python2 __builtin__ #46

Closed
user150512 opened this issue May 12, 2015 · 3 comments
Closed

fake_filesystem_unittest.py uses python2 __builtin__ #46

user150512 opened this issue May 12, 2015 · 3 comments
Labels

Comments

@user150512
Copy link

I have crash as follows

    [...]tests/__init__.py", line 17, in setUp
        self.setUpPyfakefs()
      File "/usr/local/lib/python3.4/dist-packages/pyfakefs-2.4-py3.4.egg/fake_filesystem_unittest.py", line 87, in setUpPyfakefs
        self._stubber.setUp()
      File "/usr/local/lib/python3.4/dist-packages/pyfakefs-2.4-py3.4.egg/fake_filesystem_unittest.py", line 201, in setUp
        startPatch(self, '__builtin__.file', self.fake_open)
      File "/usr/local/lib/python3.4/dist-packages/pyfakefs-2.4-py3.4.egg/fake_filesystem_unittest.py", line 198, in startPatch
        print("Warning: Could not patch '{}' on module '{}' because '{}' resolves to {}".format(attribute, target, target, patch.getter()))
      File "/usr/local/lib/python3.4/dist-packages/mock.py", line 1414, in <lambda>
        getter = lambda: _importer(target)
      File "/usr/local/lib/python3.4/dist-packages/mock.py", line 1098, in _importer
        thing = __import__(import_path)
    nose.proxy.ImportError: No module named '__builtin__'

In Line 201 of fake_filesystem_unittest.py

    startPatch(self, '__builtin__.file', self.fake_open)

the old name __builtin__ is used instead of python3 version builtins.

In mock.py as included in Traceback you can find the line

builtin = '__builtin__'
if inPy3k:
    builtin = 'builtins'
@user150512
Copy link
Author

        builtin = '__builtin__'
        if (sys.version_info[0] == 3):
            builtin='builtins'

        startPatch(self, builtin + '.file', self.fake_open)
        startPatch(self, builtin + '.open', self.fake_open)

in fake_filesystem_unittest.py yields to error:

Warning: Could not patch 'file' on module 'builtins' because 'builtins' resolves to <module 'builtins' (built-in)>
         See mock module bug 250, https://code.google.com/p/mock/issues/detail?id=250

@jmcgeheeiv
Copy link
Contributor

In issue #48 I propose a solution to this issue.

@jmcgeheeiv
Copy link
Contributor

I switched pyfakefs from mock to mox3, so this issue should be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants