NM-TAFE / civ-ipriot-in-class-demos

In class demonstrations for the IP4RIoT Cluster, NMTAFE, Northbridge, WA
Creative Commons Zero v1.0 Universal
7 stars 36 forks source link

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

Open AppleBottomSneed opened 5 months ago

AppleBottomSneed commented 5 months ago

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

rafrafavi commented 1 week ago

@AppleBottomSneed - I know it was a while ago, but I am just going through and making fixes - can you recall what the action steps were here?