3

I have something like the following, and i want to test MailReader find method setup the mock for Transport but when i try to mock only messages i get error from transport trying to open connection.

class Transport(object):
       def __init__(self, hostname, username, password, ssl):
          # something 
          pass
      def connect(self):
          pass
      def messages(self):
          pass


class MailReader(object):
  def __init__(self, hostname, username, password, ssl):
        super(Mail, self).__init__()
        self.hostname = hostname
        self.username = username
        self.password = password
        self.ssl = ssl
        self.connect()
  def connect(self):
        """
         connect to the email box
        """
        self.connection = Transport(self.hostname, self.username, self.password,
                                self.ssl)
   def find(self, search):
        messages_folder = self.connection.messages()
Cœur
  • 37,241
  • 25
  • 195
  • 267

0 Answers0