Пример #1
0
 def test_assign_sub_object_s_attributes_using_kwargs(self):
     obj = SubExample()
     assign_dict_to_obj(obj, **dict_example_2)
     self.assertEqual(obj.a, dict_example_2['a'])
     self.assertEqual(obj.b, dict_example_2['b'])
     self.assertEqual(obj.c, dict_example_2['c'])
     self.assertEqual(obj.d, dict_example_2['d'])
Пример #2
0
 def test_assign_only_attrs_that_are_both_in_class_definition_and_in_kwargs(
         self):
     obj = BaseExample()
     assign_dict_to_obj(obj, **dict_example_2)
     self.assertEqual(obj.a, dict_example_2['a'])
     self.assertEqual(obj.b, dict_example_2['b'])
     self.assertRaises(AttributeError, lambda o: o.c, obj)
     self.assertRaises(AttributeError, lambda o: o.d, obj)
Пример #3
0
 def __init__(self, **kwargs):
     self.name: str = None
     self.hand: list[Card] = None
     self.deck: list[Card] = None
     self.field: list[Card] = None
     self.graveyard: list[Card] = None
     self.resources: Resource = None
     assign_dict_to_obj(self, **kwargs)
Пример #4
0
 def __init__(self, **kwargs):
     setattr(self, User.__id_attr__, None)
     setattr(self, User.__name_attr__, None)
     setattr(self, User.__password_attr__, None)
     setattr(self, User.__token_attr__, None)
     assign_dict_to_obj(self, **kwargs)
Пример #5
0
 def test_assign_object_s_attributes_using_kwargs(self):
     obj = BaseExample()
     assign_dict_to_obj(obj, **dict_example)
     self.assertEqual(obj.a, dict_example['a'])
     self.assertEqual(obj.b, dict_example['b'])