python-benedict/tests/core/test_move.py

54 lines
1009 B
Python
Raw Normal View History

import unittest
from benedict.core import move as _move
class move_test_case(unittest.TestCase):
2022-02-13 10:35:43 +00:00
"""
This class describes a move test case.
"""
def test_move(self):
d = {
2022-02-13 10:35:43 +00:00
"a": {
"x": 1,
"y": 1,
},
2022-02-13 10:35:43 +00:00
"b": {
"x": 2,
"y": 2,
},
2022-02-13 10:35:43 +00:00
"c": {
"x": 3,
"y": 3,
},
}
2022-02-13 10:35:43 +00:00
_move(d, "a", "d")
r = {
2022-02-13 10:35:43 +00:00
"b": {
"x": 2,
"y": 2,
},
2022-02-13 10:35:43 +00:00
"c": {
"x": 3,
"y": 3,
},
2022-02-13 10:35:43 +00:00
"d": {
"x": 1,
"y": 1,
},
}
self.assertEqual(d, r)
def test_move_with_same_key(self):
d = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
}
2022-02-13 10:35:43 +00:00
_move(d, "a", "a")
r = {
2022-02-13 10:35:43 +00:00
"a": 1,
"b": 2,
}
self.assertEqual(d, r)