python-benedict/tests/core/test_remove.py

53 lines
1.0 KiB
Python
Raw Normal View History

import unittest
from benedict.core import remove as _remove
class remove_test_case(unittest.TestCase):
2022-02-13 10:35:43 +00:00
"""
This class describes a remove test case.
"""
def test_remove_with_single_key(self):
d = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
"c": 3,
}
2022-02-13 10:35:43 +00:00
_remove(d, "c")
r = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
}
self.assertEqual(d, r)
def test_remove_with_multiple_keys_as_args(self):
d = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
}
2022-02-13 10:35:43 +00:00
_remove(d, "c", "d", "e")
r = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
}
self.assertEqual(d, r)
def test_remove_with_multiple_keys_as_list(self):
d = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
}
2022-02-13 10:35:43 +00:00
_remove(d, ["c", "d", "e"])
r = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
}
self.assertEqual(d, r)