Nov-15-2020, 05:06 PM
(Nov-15-2020, 03:37 AM)deanhystad Wrote: This is the test:I was fixated on the __eq__ line of the error thinking it was an issue with that code in the Class. I wouldn't have thought to look at what I was returning from the orderPizza function. This was a humbling but valuable experience.
orderPizza()==Pizza('M',{'garlic', 'onion', 'mushroom'})orderPizza returns a string:
def orderPizza(): - snip - return f"Your pizza costs ${p.price()})"And this returns a Pizza object:
Pizza('M',{'garlic', 'onion', 'mushroom'})A Pizza object and a string will never be equal, so this test will always fail. This particular fail occurs when the Pizza.__eq__ metnod tries to compare the Pizza.size to str.size. str does not have an attribute named "size", so this throws an error.
You need to change the orderPizza function to return a Pizza.