Sha256: 066aa92f62d34d67f98be91f53ec1414ad1aec95c388ee626b775f4edaa42cc0
Contents?: true
Size: 1.2 KB
Versions: 118
Compression:
Stored size: 1.2 KB
Contents
import unittest from robot_name import Robot import random class RobotTest(unittest.TestCase): # assertRegex() alias to adress DeprecationWarning # assertRegexpMatches got renamed in version 3.2 if not hasattr(unittest.TestCase, "assertRegex"): assertRegex = unittest.TestCase.assertRegexpMatches name_re = r'^[A-Z]{2}\d{3}$' def test_has_name(self): self.assertRegex(Robot().name, self.name_re) def test_name_sticks(self): robot = Robot() robot.name self.assertEqual(robot.name, robot.name) def test_different_robots_have_different_names(self): self.assertNotEqual( Robot().name, 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) if __name__ == '__main__': unittest.main()
Version data entries
118 entries across 118 versions & 1 rubygems