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

ImportError: Import by filename is not supported #5

Open
marcosflobo opened this issue Mar 27, 2014 · 0 comments
Open

ImportError: Import by filename is not supported #5

marcosflobo opened this issue Mar 27, 2014 · 0 comments

Comments

@marcosflobo
Copy link

I'm trying to use fakeldap library with a simple example.

test_base.py

import unittest
from mock import patch
from fakeldap import MockLDAP

_mock_ldap = MockLDAP()

ldap_server = 'ldaps://myldapserver'

class BaseTests(unittest.TestCase):
    def setUp(self):
        # Patch where the ldap library is used:
        self.ldap_patcher = patch(ldap_server)
        self.mock_ldap = self.ldap_patcher.start()
        self.mock_ldap.return_value = _mock_ldap

    def tearDown(self):
        _mock_ldap.reset()
        self.mock_ldap.stop()

Dependencies:

  • python-mock-1.0.1

When I execute: python test_base.py
It raises this error:

self.mock_ldap = self.ldap_patcher.start()
  File "/usr/lib/python2.6/site-packages/mock-1.0.1-py2.6.egg/mock.py", line 1396, in start
    result = self.__enter__()
  File "/usr/lib/python2.6/site-packages/mock-1.0.1-py2.6.egg/mock.py", line 1252, in __enter__
    self.target = self.getter()
  File "/usr/lib/python2.6/site-packages/mock-1.0.1-py2.6.egg/mock.py", line 1414, in <lambda>
    getter = lambda: _importer(target)
  File "/usr/lib/python2.6/site-packages/mock-1.0.1-py2.6.egg/mock.py", line 1098, in _importer
    thing = __import__(import_path)
ImportError: Import by filename is not supported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant