Esempio n. 1
0
 def test_call_var(self):
     """FakeRandom __call__ should work with a multi-item list"""
     f = FakeRandom([1, 2, 3])
     self.assertEqual(f(), 1)
     self.assertEqual(f(), 2)
     self.assertEqual(f(), 3)
     self.assertRaises(IndexError, f)
Esempio n. 2
0
 def test_cal_var_args(self):
     """FakeRandom __call__ should ignore extra args"""
     f = FakeRandom([[1, 2, 3]], True)
     for i in range(5):
         result = f((5, 5))  # shape parameter ignored
         self.assertEqual(result, [1, 2, 3])
Esempio n. 3
0
 def test_call_var_wrap(self):
     """FakeRandom __call__ should work with a multi-item wrapped list"""
     f = FakeRandom([1, 2, 3], True)
     result = [f() for i in range(10)]
     self.assertEqual(result, [1, 2, 3, 1, 2, 3, 1, 2, 3, 1])
Esempio n. 4
0
 def test_call_constant_wrap(self):
     """FakeRandom __call__ should wrap for one-item list if specified"""
     const = FakeRandom([1], True)
     for i in range(10):
         self.assertEqual(const(), True)
Esempio n. 5
0
 def test_call_constant(self):
     """FakeRandom __call__ should return next item from list if constant"""
     const = FakeRandom([1])
     self.assertEqual(const(), 1)
     self.assertRaises(IndexError, const)