def test_forced_stop_iteration(self): """ Just for 100% coverage, force a StopIteration exception within Domain.draw(). """ domain = Domain.Domain(max_size=100) # Create custom _generate() function that can only produce 5 items # despite max_size domain._generate = lambda n: (i for i in xrange(5)) actual = domain.draw(7) # Should raise StopIteration exception within # the for loop expected = [0, 1, 2, 3, 4] self.assertItemsEqual(actual, expected)
def test_not_implemented_exception(self): """ Just for 100% coverage, confirm not implemented exception raised on Domain class's _generate function. """ domain = Domain.Domain() with self.assertRaises(NotImplementedError) as ex: g = domain._generate(10)