1def logic_mixin_factory(mass, mass_attr_name, material, material_attr_name, float_mehtod_name):
2
3 class WitchMixin:
4
5 def is_a_witch(self):
6 if (hasattr(self, mass_attr_name) and self.__dict__[mass_attr_name] == mass) or (hasattr(self, material_attr_name) and self.__dict__[material_attr_name] == material) or hasattr(self, float_mehtod_name):
7 print("Burn her!")
8 else:
9 print("No, but it's a pity, cuz she looks like a witch!")
10
11 return WitchMixin
F
Stdout:
No, but it's a pity, cuz she looks like a witch!
======================================================================
FAIL: test_realcase (test.TestWitchMixinFactory)
Real test for the Witch factory.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 30, in test_realcase
self.assertEqual(Nothing().is_a_witch(), self.RESULT_FALSE)
AssertionError: None != "No, but it's a pity, cuz she looks like a witch!"
Stdout:
No, but it's a pity, cuz she looks like a witch!
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (failures=1)
Георги Кунчев
10.11.2023 21:04Не връщаш нищо. Имаш само принтове.
Но и това, което казваш, също е проблем, да.
|
Димитър Христов
10.11.2023 19:31Гърми защото не проверявам дали float e callable?
|
09.11.2023 20:48