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

Attribute Error when finding modules #460

Closed
peteboothroyd opened this issue Dec 18, 2018 · 5 comments
Closed

Attribute Error when finding modules #460

peteboothroyd opened this issue Dec 18, 2018 · 5 comments
Labels

Comments

@peteboothroyd
Copy link

peteboothroyd commented Dec 18, 2018

Describe the bug
When using Pyfakefs with pytest an AttributeError is thrown within the _find_modules function within fake_filesystem_unittest.py. This seems to be because the __module__ Attribute does not exist on the EagerTensor from 'tensorflow.python.framework.ops'.

StackTrace:

request = <SubRequest 'fs' for <Function 'test_my_fakefs'>>

    @pytest.fixture
    def fs(request):
        """ Fake filesystem. """
        patcher = Patcher()
>       patcher.setUp()

venv/lib/python3.6/site-packages/pyfakefs/pytest_plugin.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
venv/lib/python3.6/site-packages/pyfakefs/fake_filesystem_unittest.py:495: in setUp
    self._find_modules()
venv/lib/python3.6/site-packages/pyfakefs/fake_filesystem_unittest.py:458: in _find_modules
    modules = {name: mod for name, mod in module.__dict__.items()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

.0 = <dict_itemiterator object at 0x10f372458>

    modules = {name: mod for name, mod in module.__dict__.items()
               if inspect.ismodule(mod) and
               mod.__name__ in module_names
               or inspect.isclass(mod) and
>              mod.__module__ in self._class_modules.get(name, [])}
E   AttributeError: __module__

venv/lib/python3.6/site-packages/pyfakefs/fake_filesystem_unittest.py:462: AttributeError

How To Reproduce
Run with tensorflow imported

** Your enviroment**

python -c "import platform; print(platform.platform())": Darwin-18.2.0-x86_64-i386-64bit
python -c "import sys; print('Python', sys.version)": [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)": pyfakefs 3.5.3
@peteboothroyd
Copy link
Author

Note that for recent releases of tensorflow this has been fixed however I can't currently move to the most recent TensorFlow version.

@mrbean-bremen
Copy link
Member

Thanks for the report - I will have a look in the evening. Should be an easy fix - I wasn't aware that this may happen (e.g. missing __module__).
For your use case, are you comfortable with the fix in master, or do you need a new PyPi release?

@peteboothroyd
Copy link
Author

peteboothroyd commented Dec 19, 2018

Great thanks for the quick response! A new PyPi release would be ideal if possible.

@mrbean-bremen
Copy link
Member

Ok, I uploaded a new version to PyPi. Please check if that works for you.

@peteboothroyd
Copy link
Author

Thank you I can confirm that this fixes the issue on my end. Appreciate the super quick response!

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

2 participants