class IntersectionTests(unittest.TestCase): def setUp(self): self.st1 = 'A' self.st2 = 'B' self.intersection = Intersection(self.st1, self.st2) def test_should_go_if_green(self): light1 = self.intersection.lightat(self.st1) if light1 == TrafficLight.GREEN: self.assertTrue(self.intersection.green(self.st1)) self.assertFalse(self.intersection.green(self.st2)) else: self.assertTrue(self.intersection.green(self.st2)) self.assertFalse(self.intersection.green(self.st1)) def test_should_be_equal(self): test_intersection = Intersection(self.st1, self.st2) test_intersection_swap = Intersection(self.st2, self.st1) self.assertEqual(test_intersection, self.intersection) self.assertEqual(test_intersection_swap, test_intersection)
def setUp(self): self.st1 = 'A' self.st2 = 'B' self.intersection = Intersection(self.st1, self.st2)