old_contents: # Tai Sakuma <tai.sakuma@gmail.com>
  from alphatwirl.selection.modules import NotwCount
  import unittest
  
  ##__________________________________________________________________||
  class MockEvent(object): pass
  
  ##__________________________________________________________________||
  class MockEventSelection(object):
      def __init__(self, name = None):
          self.name = name
          self.is_begin_called = False
          self.is_end_called = False
          self.ret = True
  
      def begin(self, event):
          self.is_begin_called = True
  
      def __call__(self, event):
          return self.ret
  
      def end(self):
          self.is_end_called = True
  
  ##__________________________________________________________________||
  class Test_NotwCount(unittest.TestCase):
  
      def test_standard(self):
  
          sel1 = MockEventSelection(name = 'sel1')
          obj = NotwCount(selection = sel1)
  
          self.assertFalse(sel1.is_begin_called)
  
          self.assertFalse(sel1.is_end_called)
  
          event = MockEvent()
          obj.begin(event)
          self.assertTrue(sel1.is_begin_called)
  
          event = MockEvent()
          sel1.ret = False   # 1/1
          self.assertTrue(obj(event))
  
          event = MockEvent()
          sel1.ret = True  # 1/2
          self.assertFalse(obj.event(event))
  
          obj.end()
          self.assertTrue(sel1.is_end_called)
  
          count = obj.results()
          self.assertEqual(
              [
                  [1, 'MockEventSelection', 'sel1', 1, 2],
              ],
              count._results
          )
  
  ##__________________________________________________________________||
  
new_contents: # Tai Sakuma <tai.sakuma@gmail.com>
  import pytest
  
  try:
      import unittest.mock as mock
  except ImportError:
      import mock
  
  from alphatwirl.selection.modules import NotwCount
  
  ##__________________________________________________________________||
  class MockEventSelection(object):
      def begin(self, event): pass
      def __call__(self, event): pass
      def end(self): pass
  
  @pytest.fixture()
  def sel1():
      ret = mock.Mock(spec=MockEventSelection)
      ret.name ='sel1'
      sel1.return_value = True
      return ret
  
  @pytest.fixture()
  def obj(sel1):
      return NotwCount(selection=sel1)
  
  def test_repr(obj):
      repr(obj)
  
  def test_standard(obj, sel1):
  
      assert [ ] == sel1.begin.call_args_list
      assert [ ] == sel1.end.call_args_list
  
  
      event = mock.Mock()
      obj.begin(event)
      assert [mock.call(event)] == sel1.begin.call_args_list
  
      event = mock.Mock()
      sel1.return_value = False   # 1/1
      assert obj(event)
  
      event = mock.Mock()
      sel1.return_value = True   # 1/2
      assert not obj(event)
  
      obj.end()
      assert [mock.call()] == sel1.end.call_args_list
  
      count = obj.results()
      assert [
          [1, 'MockEventSelection', 'sel1', 1, 2],
      ] == count._results
  
  ##__________________________________________________________________||
  
subject: rewrite tests for NotwCount with pytest