#! /usr/bin/python3
import random
class Takefive():
"""
Create a random number generator.
"""
def __init__(self):
self.my_gen = (random.randint(1,100) for i in range(5))
def test_generator_comprehension():
rest = Takefive()
try:
count = 0
print("\n")
for i in range(5):
print(next(rest.my_gen))
count += 1
except StopIteration:
assert count == 5
else:
print("Confirm exhaustion of generator")
try:
print(next(rest.my_gen))
count += 1
except StopIteration:
pass
else:
assert count == 5