old_contents: import unittest
  from alphatwirl.loop import EventLoopRunner
  
  ##__________________________________________________________________||
  class MockResult(object): pass
  
  ##__________________________________________________________________||
  class MockEventLoop(object):
      def __init__(self, result):
          self.result = result
  
      def __call__(self, progressReporter):
          return self.result
  
  ##__________________________________________________________________||
  class TestEventLoopRunner(unittest.TestCase):
  
      def setUp(self):
          self.obj = EventLoopRunner()
  
      def test_repr(self):
          repr(self.obj)
  
      def test_begin(self):
          self.obj.begin()
  
      def test_end(self):
          self.obj.begin()
          self.assertEqual([ ], self.obj.end())
  
      def test_end_without_begin(self):
          self.assertEqual([ ], self.obj.end())
  
      def test_run(self):
          self.obj.begin()
  
          result1 = MockResult()
          loop1 = MockEventLoop(result1)
          self.obj.run(loop1)
  
          result2 = MockResult()
          loop2 = MockEventLoop(result2)
          self.obj.run(loop2)
  
          self.assertEqual([result1, result2], self.obj.end())
  
  ##__________________________________________________________________||
  
new_contents: # Tai Sakuma <tai.sakuma@gmail.com>
  import logging
  import pytest
  
  try:
      import unittest.mock as mock
  except ImportError:
      import mock
  
  from alphatwirl.loop import EventLoopRunner
  
  ##__________________________________________________________________||
  @pytest.fixture()
  def progressReporter():
      return mock.Mock(name='progressReporter')
  
  @pytest.fixture()
  def progressMonitor(progressReporter):
      ret = mock.Mock(name='progressMonitor')
      ret.createReporter.return_value = progressReporter
      return ret
  
  @pytest.fixture()
  def obj(progressMonitor):
      return EventLoopRunner(progressMonitor=progressMonitor)
  
  ##__________________________________________________________________||
  def test_repr(obj):
     repr(obj)
  
  def test_begin(obj):
      obj.begin()
  
  def test_end(obj):
      obj.begin()
      assert [ ] == obj.end()
  
  def test_run(obj, progressReporter):
      obj.begin()
  
      result1 = mock.Mock(name='result1')
      eventLoop1 = mock.Mock(name='eventLoop1')
      eventLoop1.return_value = result1
      obj.run(eventLoop1)
  
      assert [mock.call(progressReporter=progressReporter)] == eventLoop1.call_args_list
  
      result2 = mock.Mock(name='result2')
      eventLoop2 = mock.Mock(name='eventLoop2')
      eventLoop2.return_value = result2
      obj.run(eventLoop2)
  
      assert [mock.call(progressReporter=progressReporter)] == eventLoop2.call_args_list
  
      assert [result1, result2] == obj.end()
  
  ##__________________________________________________________________||
  
  
subject: replace unittest with pytest