Example #1
0
 def test_deepops_remove_list_from_dict(self):
     x_remove_z = {"c": ["x"],
                   "d": {"m": "x",
                         "n": 3,
                         "p": [1, 2],
                         "q": {"t": [1]}},
                   "e": {7, 8}}
     deepops.deepremoveitems(self.x, self.z_list)
     self.assertEqual(x_remove_z, self.x)
Example #2
0
    def test_deepops_remove(self):
        x_remove_z = {"c": [],
                      "d": {"m": "x",
                            "n": 3,
                            "p": [1, 2],
                            "q": {"t": [1]}},
                      "e": {8, 7}}

        deepops.deepremoveitems(self.x, self.z)
        self.assertEqual(x_remove_z, self.x)
Example #3
0
 def test_remove_list_from_dict(self):
     x_remove_z = {
         "c": ["x"],
         "d": {"m": "x",
             "n": 3,
             "p": [1, 2],
             "q": {
                 "t": [1],
             },
         },
         "e": {7, 8},
     }
     deepremoveitems(self.x, self.z_list)
     self.assertEqual(x_remove_z, self.x)
Example #4
0
    def test_remove(self):
        x_remove_z = {
            "c": [],
            "d": {
                "m": "x",
                "n": 3,
                "p": [1, 2],
                "q": {
                    "t": [1],
                },
            },
            "e": {8, 7},
        }

        deepremoveitems(self.x, self.z)
        self.assertEqual(x_remove_z, self.x)
Example #5
0
 def test_remove_compound_from_simple_filtered(self):
     x_remove_const = {
         "b": 2,
         "c": ["x"],
         "d": {"m": "x",
             "n": 3,
             "p": [1, 2],
             "q": {
                 "t": [1],
             },
         },
         "e": {7, 8},
     }
     deepremoveitems(
         self.x, {"a": {}, "d": {"n": [1]}},
         filter_func=lambda p, a, b: not p.startswith(["d", "n"]))
     self.assertEqual(x_remove_const, self.x)
Example #6
0
 def test_deepops_remove_dict_from_list(self):
     x_remove_z = ["c", "d"]
     deepops.deepremoveitems(self.x_list, self.z_dict_from_list)
     self.assertEqual(x_remove_z, self.x_list)
Example #7
0
 def test_deepops_remove_empty_dict_from_list(self):
     x_remove_z = ["a", "b", "c", "d"]
     deepops.deepremoveitems(self.x_list, {})
     self.assertEqual(x_remove_z, self.x_list)
Example #8
0
 def test_diff_remove_update(self):
     diff_remove, diff_update = deepdiff(self.x, self.y)
     deepremoveitems(self.x, deepcopy(diff_remove))
     deepmerge(self.x, deepcopy(diff_update))
     self.assertEqual(self.x, self.y)
Example #9
0
 def test_remove_dict_from_list(self):
     x_remove_z = ["c", "d"]
     deepremoveitems(self.x_list, self.z_dict_from_list)
     self.assertEqual(x_remove_z, self.x_list)
Example #10
0
 def test_remove_empty_dict_from_list(self):
     x_remove_z = ["a", "b", "c", "d"]
     deepremoveitems(self.x_list, {})
     self.assertEqual(x_remove_z, self.x_list)
Example #11
0
     "d": {"m": "y",
           "o": 4,
           "p": [2, 3],
           "q": {"t": [2]}},
     "e": {8, 9}}

# something complex to remove

z = {"a": {},
     "b": {},
     "c": {"x": {}},
     "t": {"n": {}}}

# do some testing, printing the sources and outputs

print("MERGE >")
print("  into:", x)
print("  from:", y)
deepops.deepmerge(x, y, list_as_set=True)
print("MERGED >")
print(" ", x)

print()

print("REMOVE >")
print("  from:", x)
print("  items:", z)
deepops.deepremoveitems(x, z)
print("REMOVED >")
print(" ", x)
Example #12
0
 def test_deepops_remove_list(self):
     x_remove_z = ["c", "d"]
     deepops.deepremoveitems(self.x_list, self.z_list)
     self.assertEqual(x_remove_z, self.x_list)