예제 #1
0
 def test_dictionary_of_custom_objects(self):
     member1 = CustomClass(13, 37)
     member2 = CustomClass(13, 37)
     t1 = {1: member1}
     t2 = {1: member2}
     ddiff = DeepDiff(t1, t2)
     result = {}
     assert result == ddiff
예제 #2
0
 def test_set_of_custom_objects(self):
     member1 = CustomClass(13, 37)
     member2 = CustomClass(13, 37)
     t1 = {member1}
     t2 = {member2}
     ddiff = DeepDiff(t1, t2)
     result = {}
     self.assertEqual(ddiff, result)
예제 #3
0
    def test_skip_dictionary_path_with_custom_object(self):
        obj1 = CustomClass(1)
        obj2 = CustomClass(2)

        t1 = {1: {2: obj1}}
        t2 = {1: {2: obj2}}
        ddiff = DeepDiff(t1, t2, exclude_paths=['root[1][2].a'])
        result = {}
        assert result == ddiff
예제 #4
0
 def test_custom_objects_change(self):
     t1 = CustomClass(1)
     t2 = CustomClass(2)
     ddiff = DeepDiff(t1, t2)
     result = {
         'values_changed': {
             'root.a': {
                 'old_value': 1,
                 'new_value': 2
             }
         }
     }
     assert result == ddiff
예제 #5
0
    def setUp(self):
        # Test data
        self.custom1 = CustomClass(a='very long text here', b=37)
        self.custom2 = CustomClass(a=313, b=37)
        self.t1 = {42: 'answer', 'vegan': 'for life', 1337: self.custom1}
        self.t2 = {
            42: 'answer',
            'vegan': 'for the animals',
            1337: self.custom2
        }

        # Manually build diff, bottom up
        self.lowest = DiffLevel(self.custom1.a,
                                self.custom2.a,
                                report_type='values_changed')

        # Test manual child relationship
        rel_int_low_t1 = AttributeRelationship(parent=self.custom1,
                                               child=self.custom1.a,
                                               param="a")
        rel_int_low_t2 = AttributeRelationship(parent=self.custom2,
                                               child=self.custom2.a,
                                               param="a")
        self.intermediate = DiffLevel(self.custom1,
                                      self.custom2,
                                      down=self.lowest,
                                      child_rel1=rel_int_low_t1,
                                      child_rel2=rel_int_low_t2)
        self.lowest.up = self.intermediate

        # Test automatic child relationship
        t1_child_rel = ChildRelationship.create(klass=DictRelationship,
                                                parent=self.t1,
                                                child=self.intermediate.t1,
                                                param=1337)
        t2_child_rel = ChildRelationship.create(klass=DictRelationship,
                                                parent=self.t2,
                                                child=self.intermediate.t2,
                                                param=1337)
        self.highest = DiffLevel(self.t1,
                                 self.t2,
                                 down=self.intermediate,
                                 child_rel1=t1_child_rel,
                                 child_rel2=t2_child_rel)
        self.intermediate.up = self.highest
예제 #6
0
 def setup_class(cls):
     cls.customkey = CustomClass(a=13, b=37)
     cls.customkey_misleading = CustomClassMisleadingRepr(a=11, b=20)
     cls.d = {
         42: 'answer',
         'vegan': 'for life',
         cls.customkey: 1337,
         cls.customkey_misleading: 'banana'
     }
예제 #7
0
 def setUp(self):
     self.customkey = CustomClass(a=13, b=37)
     self.customkey_misleading = CustomClassMisleadingRepr(a=11, b=20)
     self.d = {
         42: 'answer',
         'vegan': 'for life',
         self.customkey: 1337,
         self.customkey_misleading: 'banana'
     }
예제 #8
0
 def test_skip_custom_object_path(self):
     t1 = CustomClass(1)
     t2 = CustomClass(2)
     ddiff = DeepDiff(t1, t2, exclude_paths=['root.a'])
     result = {}
     assert result == ddiff
예제 #9
0
 def test_get_item_length_custom_class2_loop(self):
     item = CustomClass(a=10)
     item.b = item
     item_length = _get_item_length(item)
     assert 2 == item_length
예제 #10
0
 def setup_class(cls):
     cls.custom = CustomClass(13, 37)
예제 #11
0
 def setup_class(cls):
     cls.custom = CustomClass(13, 37)
     cls.l = [1337, 'vegan', cls.custom]
예제 #12
0
 def setUp(self):
     self.custom = CustomClass(13, 37)
     self.l = [1337, 'vegan', self.custom]
예제 #13
0
 def setUp(self):
     self.custom = CustomClass(13, 37)