def test_reset_name(self): # Set a seed seed = "Totally random." # Initialize RNG using the seed random.seed(seed) # Call the generator robot = Robot() name = robot.name # Reinitialize RNG using seed random.seed(seed) # Call the generator again robot.reset() name2 = robot.name self.assertNotEqual(name, name2) self.assertRegex(name2, self.name_re)
def test_infinite_robots_throws_exception(self): with self.assertRaises(Exception): name_permutations = (len(string.ascii_uppercase)**2) * (len( string.digits)**3) for _ in range(name_permutations + 1): # +1 just in case the stars _really_ align Robot().name
def test_reset_name(self): # Set a seed seed = "Totally random." # Initialize RNG using the seed random.seed(seed) # Call the generator robot = Robot() name = robot.name # Reinitialize RNG using seed random.seed(seed) # Call the generator again robot.reset() name2 = robot.name self.assertNotEqual(name, name2) self.assertRegex(name2, self.name_re)
def test_different_robots_have_different_names(self): self.assertNotEqual(Robot().name, Robot().name)
def test_name_sticks(self): robot = Robot() robot.name self.assertEqual(robot.name, robot.name)
def test_has_name(self): self.assertRegex(Robot().name, self.name_re)
def test_name_sticks(self): robot = Robot() # robot.name # Statement seems to have no effect self.assertEqual(robot.name, robot.name)
def test_has_name(self): actual = Robot().name # print('Robot name: ' + actual) self.assertRegex(actual, self.name_re)