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

Regression: modules_to_patch fails if fake module has no dir() method #450

Closed
mrbean-bremen opened this issue Nov 8, 2018 · 1 comment
Closed
Labels

Comments

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Nov 8, 2018

The following code, taken from the documentation:

class DummyLocks(object):
    _locks_module = django.core.files.locks

    def __init__(self, fs):
        pass

    @staticmethod
    def lock(f, flags):
        return True

    @staticmethod
    def unlock(f):
        return True

    def __getattr__(self, name):
        """Forwards any non-faked calls to the standard module."""
        return getattr(self._locks_module, name)


class FakeFSTestCase(pyfakefs.fake_filesystem_unittest.TestCase):
    def __init__(self, methodName='runTest'):
        pyfakefs.fake_filesystem_unittest.TestCase.__init__(
            self, methodName, modules_to_patch={'locks': DummyLocks})

yields

Traceback (most recent call last):
  File "D:\..\tests\testUploadFilesView.py", line 33, in setUp
    self.setUpPyfakefs()
  File "D:\..\lib\site-packages\pyfakefs\fake_filesystem_unittest.py", line 187, in setUpPyfakefs
    modules_to_patch=modules_to_patch)
  File "D:\..\lib\site-packages\pyfakefs\fake_filesystem_unittest.py", line 350, in __init__
    for fct_name in fake_module.dir():
AttributeError: type object 'DummyLocks' has no attribute 'dir'
@mrbean-bremen
Copy link
Member Author

While this problem has been fixed, the example still does not work.
Reopen.

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

1 participant