Skip to content

For those stuck on the first unit tests (Spoilers) #5

Description

@AppleBottomSneed

Remember to check the errors the unit tests throw at you and have a thorough look on why it is.

In this case, under test_car_park.py:

def test_car_park_initialized_with_all_attributes(self):
    self.assertIsInstance(self.car_park, CarPark)
    self.assertEqual(self.car_park.location, "123 Example Street")
    self.assertEqual(self.car_park.capacity, 100)
    self.assertEqual(self.car_park.plates, [])
    self.assertEqual(self.car_park.sensors, [])
    self.assertEqual(self.car_park.displays, [])
    self.assertEqual(self.car_park.available_bays, 100)

I overlooked it and forgot to properly instance the lists as they're mutable and should never be set as the default by itself i.e. plates, sensors and displays. Hope this helps

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions