コード例 #1
0
 def setUp(self):
     self.cross_street = 2.5
     self.cross_block = 10
     self.wait_intersection = 5
     self.timekeeper = TimeKeeper(self.cross_street, self.cross_block, self.wait_intersection)
コード例 #2
0
class TimeKeeperTests(unittest.TestCase):
    def setUp(self):
        self.cross_street = 2.5
        self.cross_block = 10
        self.wait_intersection = 5
        self.timekeeper = TimeKeeper(self.cross_street, self.cross_block, self.wait_intersection)

    def test_add_cross_street_time(self):
        orig_time = self.timekeeper.output_time()
        self.timekeeper.track_cross()
        new_time = self.timekeeper.output_time()
        self.assertEqual(new_time, orig_time + self.cross_street)

    def test_add_cross_block_time(self):
        orig_time = self.timekeeper.output_time()
        self.timekeeper.track_walk_block()
        new_time = self.timekeeper.output_time()
        self.assertEqual(new_time, orig_time + self.cross_block)

    def test_add_wait_intersection_time(self):
        orig_time = self.timekeeper.output_time()
        self.timekeeper.track_wait()
        new_time = self.timekeeper.output_time()
        self.assertEqual(new_time, orig_time + self.wait_intersection)