Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # themod/sql.py
- class PostgresStore(object):
- def __init__(self, host, port):
- self.host = host
- self.port = port
- def connect(self):
- self._conn = "%s:%s" % (self.host, self.port)
- return self._conn
- # themod/repository.py
- from .sql import PostgresStore
- class Repository(PostgresStore):
- def freak_count(self):
- pass
- # tests/test.py
- from themod.repository import Repository
- from mock import patch
- @patch('themod.repository.PostgresStore', autospec=True)
- def patched(thepatch):
- # print(thepatch)
- x = Repository('a', 'b')
- #### how to mock the call to x.connect?
- print(x.connect())
- patched()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement