Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. # themod/sql.py
  2.  
  3. class PostgresStore(object):
  4. def __init__(self, host, port):
  5. self.host = host
  6. self.port = port
  7.  
  8. def connect(self):
  9. self._conn = "%s:%s" % (self.host, self.port)
  10. return self._conn
  11.  
  12.  
  13. # themod/repository.py
  14. from .sql import PostgresStore
  15.  
  16.  
  17. class Repository(PostgresStore):
  18.  
  19. def freak_count(self):
  20. pass
  21.  
  22.  
  23. # tests/test.py
  24. from themod.repository import Repository
  25. from mock import patch
  26.  
  27. @patch('themod.repository.PostgresStore', autospec=True)
  28. def patched(thepatch):
  29. # print(thepatch)
  30. x = Repository('a', 'b')
  31.  
  32. #### how to mock the call to x.connect?
  33. print(x.connect())
  34.  
  35. patched()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement