def test_exponential_base_sequence(self): """ Ensure that an exponential sequence with a different base works. """ sequence = ExponentialSequence(base=10) for idx in xrange(1, 1000): self.assertEqual(sequence.next(), 10**idx)
def test_exponential_unit_sequence(self): """ Ensure an "infinite" exponential sequence works as expected. """ sequence = ExponentialSequence() for idx in xrange(1, 1000): self.assertEqual(sequence.next(), 2**idx)
def test_exponential_limit_sequence(self): """ Ensure that a sequence can be limited. """ with self.assertRaises(StopIteration): sequence = ExponentialSequence(limit=1000) for idx in xrange(1, 100000): self.assertEqual(sequence.next(), 2**idx)