Example #1
0
class TestPlane(unittest.TestCase):
    def setUp(self):
        self.plane = Plane()
        self.plane.land()

    def test_land_sets_grounded_status_to_true(self):
        self.assertEqual(self.plane.grounded, True)

    def test_land_raises_error_if_plane_grounded(self):
        self.assertRaises(TypeError, self.plane.land)

    def test_take_off_sets_grounded_status_to_false(self):
        self.plane.take_off()
        self.assertEqual(self.plane.grounded, False)

    def test_take_off_raises_error_if_plane_not_grounded(self):
        self.plane.take_off()
        self.assertRaises(TypeError, self.plane.take_off)
Example #2
0
class PlaneTest(unittest.TestCase):
    def setUp(self):
        self.plane = Plane()

    def test_planes_can_take_off(self):
        self.plane.take_off()
        self.assertTrue(self.plane.flying, 'plane does not correctly take off')

    def test_planes_can_land(self):
        self.plane.take_off()
        self.plane.land()
        self.assertFalse(self.plane.flying, 'plane does not correctly land')

    def test_flying_planes_cannot_take_off(self):
        self.plane.take_off()
        with self.assertRaises(Exception): 
            self.plane.take_off()
            
    def test_landed_planes_cannot_land(self):
        self.plane.land()
        with self.assertRaises(Exception):
            self.plane.land()
Example #3
0
def test_plane_is_not_landed_after_having_landed_and_takenoff():
    plane = Plane()
    plane.land()
    plane.takeoff()

    assert plane.is_landed() == False
Example #4
0
def test_plane_is_landed_after_having_landed():
    plane = Plane()
    plane.land()

    assert plane.is_landed() == True