Ejemplo n.º 1
0
class HardTestCase(unittest.TestCase):
    def setUp(self):
        self.car = Car()
        self.car.start_car()

    def test_hard_input(self):
        self.car.add_speed()
        self.car.add_speed()
        self.car.remove_speed()
        self.car.remove_speed()
        self.car.remove_speed()
        self.car.remove_speed()
        self.assertEqual(self.car.current_speed(), 0)

    def test_hard_input_two(self):
        self.car.add_speed()
        self.car.add_speed()
        self.car.stop()
        self.car.stop()
        self.assertEqual(self.car.current_speed(), 0)

    def tearDown(self):
        self.car.stop()
        self.car.turn_off_car()
        self.car = None
Ejemplo n.º 2
0
class MediumTestCase(unittest.TestCase):

    def setUp(self):
        self.car = Car()
        self.car.start_car()

    def test_medium_input(self):
        with self.assertRaises(Exception):
            self.car.start_car()

    def test_medium_input_two(self):
        self.car.remove_speed()
        self.car.remove_speed()
        self.car.remove_speed()
        self.car.remove_speed()
        self.assertEqual(self.car.current_speed(), 0)

    def tearDown(self):
        self.car.stop()
        self.car.turn_off_car()
        self.car = None
Ejemplo n.º 3
0
class HardTestCase(unittest.TestCase):
    def setUp(self):
        # Todo: create an object named car from the Car class
        # Todo: use the object car to start the car.
        self.car = Car()
        self.car.start_car()

    def test_hard_input(self):
        # Todo: use the object car to add speed 2 times.
        # Todo: use the object car to remove speed 4 times.
        # Todo: make sure that the current speed is 0.
        for _ in range(0, 2):
            self.car.add_speed()

        for _ in range(0, 4):
            self.car.remove_speed()  # need to update the remove method:done

        self.assertEqual(self.car._speed, 0)
        self.assertEqual(self.car.current_speed(), 0)

    def test_hard_input_two(self):
        # Todo: use the object car to add speed 2 times.
        # Todo: stop the car.
        # Todo: stop the car.
        # Todo: stop the car.
        # Todo: make sure that the current speed is 0.
        self.car.add_speed()
        self.car.add_speed()
        self.car.stop()
        self.assertEqual(self.car.current_speed(), 0)

    def tearDown(self):
        # Todo: stop the car.
        # Todo: turn off the car.
        # Todo: set the object car to None.
        self.car.stop()  # stops the car
        self.car.turn_off_car()  # turn off the car
        self.car = None