How to use deepdiff - 10 common examples

To help you get started, we’ve selected a few deepdiff examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seperman / deepdiff / tests / test_hash.py View on Github external
def test_prep_str_murmur3_128bit(self):
        obj = "a"
        expected_result = {
            obj: 119173504597196970070553896747624927922
        }
        result = DeepHash(obj, ignore_string_type_changes=True, hasher=DeepHash.murmur3_128bit)
        assert expected_result == result
github seperman / deepdiff / tests / test_hash.py View on Github external
def test_prep_str_murmur3_64bit(self):
        obj = "a"
        expected_result = {
            obj: 424475663186367154
        }
        result = DeepHash(obj, ignore_string_type_changes=True, hasher=DeepHash.murmur3_64bit)
        assert expected_result == result
github projectcalico / node / tests / k8st / test_base.py View on Github external
def assert_same(thing1, thing2):
        """
        Compares two things.  Debug logs the differences between them before
        asserting that they are the same.
        """
        assert cmp(thing1, thing2) == 0, \
            "Items are not the same.  Difference is:\n %s" % \
            pformat(DeepDiff(thing1, thing2), indent=2)
github seperman / deepdiff / tests / diff_tests.py View on Github external
def test_negative_significant_digits(self):
        with self.assertRaises(ValueError):
            DeepDiff(1, 1, significant_digits=-1)
github seperman / deepdiff / tests / test_diff_text.py View on Github external
def test_nested_list_with_dictionarry_difference_ignore_order(self):
        t1 = [1, 2, [3, 4, {1: 2}]]
        t2 = [[4, 3, {1: 2}], 2, 1]

        ddiff = DeepDiff(t1, t2, ignore_order=True)

        result = {}
        assert result == ddiff
github seperman / deepdiff / tests / test_diff_text.py View on Github external
def test_type_change_numeric_when_ignore_order(self, t1, t2, expected_result):
        ddiff = DeepDiff(t1, t2, ignore_order=True, ignore_numeric_type_changes=True, ignore_string_type_changes=True)
        assert expected_result == ddiff
github graphql-python / gql-next / tests / test_query_parser.py View on Github external
fields=[
                                    ParsedField(name='title', type='str', nullable=False),
                                    ParsedField(name='director', type='str', nullable=False),
                                ]
                            )
                        ]
                    )
                ]
            )
        ]
    ))

    parsed_dict = asdict(parsed)

    assert bool(parsed)
    assert parsed_dict == expected, str(DeepDiff(parsed_dict, expected))
github seperman / deepdiff / tests / test_diff_tree.py View on Github external
def test_same_objects(self):
        t1 = {1: 1, 2: 2, 3: 3}
        t2 = t1
        ddiff = DeepDiff(t1, t2)
        res = ddiff.tree
        self.assertEqual(res, {})
github seperman / deepdiff / tests / test_hash_tree.py View on Github external
def test_same_dict_in_list_same_hash(self):
        t1 = [{'b': 5, 'c': 4}]
        t2 = [{'b': 5, 'c': 4}]
        hash1 = DeepHash(t1, view='tree')
        hash2 = DeepHash(t2, view='tree')
        self.assertEqual(hash1["hash"].hash(), hash2["hash"].hash())
github seperman / deepdiff / tests / test_hash_tree.py View on Github external
def test_same_dict_same_hash(self):
        t1 = {'b': 5, 'c': 4}
        t2 = {'b': 5, 'c': 4}
        hash1 = DeepHash(t1, view='tree', hasher=sha1)
        hash2 = DeepHash(t2, view='tree', hasher=sha1)
        self.assertEqual(hash1["hash"].hash(), hash2["hash"].hash())