title: Returning multiple objects from a pytest fixture
body: <p>I am learning how to use pytest by testing a simple event emitter implementation.</p>
  
  <p>Basically, it looks like this</p>
  
  <pre><code>class EventEmitter():
      def __init__(self):
          ...
      def subscribe(self, event_map):
          # adds listeners to provided in event_map events
      def emit(self, event, *args):
          # emits event with given args
  </code></pre>
  
  <p>For convenience, I created a <code>Listener</code> class that is used in tests</p>
  
  <pre><code>class Listener():
      def __init__(self):
          ...
      def operation(self):
          # actual listener
  </code></pre>
  
  <p>Currently, test looks the following way</p>
  
  <pre><code>@pytest.fixture
  def event():
      ee = EventEmitter()
      lstr = Listener()
      ee.subscribe({"event" : [lstr.operation]})
      return lstr, ee
  
  def test_emitter(event):
      lstr = event[0]
      ee = event[1]
      ee.emit("event")
      assert lstr.result == 7 # for example
  </code></pre>
  
  <p>In order to test event emitter, I need to check whether the inner state of the listener has changed after event propagation. Thus, I need two objects and I wonder if there is a better way to do this (maybe use two fixtures instead of one somehow) because this looks kinda ugly to me.</p>