new_contents: import unittest
  
  from chainer.testing import condition
  
  
  # The test fixtures of this TestCase is used to be decorated by
  # decorator in test. So we do not run them alone.
  class MockUnitTest(unittest.TestCase):
  
      counter = 0
  
      def failure_case(self):
          self.fail()
  
      def success_case(self):
          self.assertTrue(True)
  
      def probabilistic_case(self):
          self.counter += 1
          if self.counter % 2 == 0:
              self.assertTrue(True)
          else:
              self.fail()
  
      def runTest(self):
          pass
  
  
  def _should_fail(self, f):
      self.assertRaises(AssertionError, f, self.unit_test)
  
  
  def _should_pass(self, f):
      f(self.unit_test)
  
  
  class TestRepeatWithSuccessAtLeast(unittest.TestCase):
  
      def _decorate(self, f, times, min_success):
          return condition.repeat_with_success_at_least(
              times, min_success)(f)
  
      def setUp(self):
          self.unit_test = MockUnitTest()
  
      def test_all_trials_fail(self):
          f = self._decorate(MockUnitTest.failure_case, 10, 1)
          _should_fail(self, f)
  
      def test_all_trials_fail2(self):
          f = self._decorate(MockUnitTest.failure_case, 10, 0)
          _should_pass(self, f)
  
      def test_all_trials_succeed(self):
          f = self._decorate(MockUnitTest.success_case, 10, 10)
          _should_pass(self, f)
  
      def test_all_trials_succeed2(self):
          self.assertRaises(AssertionError,
                            condition.repeat_with_success_at_least,
                            10, 11)
  
      def test_half_of_trials_succeed(self):
          f = self._decorate(MockUnitTest.probabilistic_case, 10, 5)
          _should_pass(self, f)
  
      def test_half_of_trials_succeed2(self):
          f = self._decorate(MockUnitTest.probabilistic_case, 10, 6)
          _should_fail(self, f)
  
  
  class TestRepeat(unittest.TestCase):
  
      def _decorate(self, f, times):
          return condition.repeat(times)(f)
  
      def setUp(self):
          self.unit_test = MockUnitTest()
  
      def test_failure_case(self):
          f = self._decorate(MockUnitTest.failure_case, 10)
          _should_fail(self, f)
  
      def test_success_case(self):
          f = self._decorate(MockUnitTest.success_case, 10)
          _should_pass(self, f)
  
      def test_probabilistic_case(self):
          f = self._decorate(MockUnitTest.probabilistic_case, 10)
          _should_fail(self, f)
  
  
  class TestRetry(unittest.TestCase):
  
      def _decorate(self, f, times):
          return condition.retry(times)(f)
  
      def setUp(self):
          self.unit_test = MockUnitTest()
  
      def test_failure_case(self):
          f = self._decorate(MockUnitTest.failure_case, 10)
          _should_fail(self, f)
  
      def test_success_case(self):
          f = self._decorate(MockUnitTest.success_case, 10)
          _should_pass(self, f)
  
      def test_probabilistic_case(self):
          f = self._decorate(MockUnitTest.probabilistic_case, 10)
          _should_pass(self, f)
  
subject: Add unittest for condition decorators