title: How can I mock an instance of a class?
body: <p>I have the below code, and I am trying to mock out <code>exg.metadata</code></p>
  <pre><code>class data:
      def __init__(self): 
          pass
  
  
      def trade_status(self, exg, fields, values, msgtype, sequence):
          ... 
          if security_id in exg.metadata:
              market_seg = exg.metadata[security_id]['market_segment']
              exg.write_meta(security_id, exg.metadata.pop(security_id))
              self._send_tick_size_rules(exg, security_id, market_seg)
  </code></pre>
  <p>It may help to state that when I <code>print(type(exg))</code> I get a class (<code>&lt;class 'exchanges.impl.bate.parser.Exchange'&gt;</code>). I'm not exactly sure what <code>exg</code> is, any idea how I can find out? When I print it, all it says is <code>BATES</code>, which looks like a string but it's clearly not.</p>
  <p>Also, it may help to see what the exchange looks like:</p>
  <pre><code>class BATSExchange(exchanges.L3Exchange):
      protocol = None
      data_file_type = quote.BatseurBook
      package_buffer = None
      buffer_capacity = 1000000
      multiple_files = True
  
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          # store meta and tick size content
          self.metadata = {}
  </code></pre>
  <p>Do I mock the exchange?</p>