Skip to content

Commit a5e9f91

Browse files
committed
Add test for get_parts (new method)
1 parent 73cb9ef commit a5e9f91

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,31 @@ def test_round_trip(self):
7070
ptr = JsonPointer(path)
7171
self.assertEqual(path, ptr.path)
7272

73-
parts = ptr.parts
73+
parts = ptr.get_parts()
74+
self.assertEqual(parts, ptr.parts)
7475
new_ptr = JsonPointer.from_parts(parts)
7576
self.assertEqual(ptr, new_ptr)
7677

78+
def test_parts(self):
79+
paths = [
80+
("", []),
81+
("/foo", ['foo']),
82+
("/foo/0", ['foo', '0']),
83+
("/", ['']),
84+
("/a~1b", ['a/b']),
85+
("/c%d", ['c%d']),
86+
("/e^f", ['e^f']),
87+
("/g|h", ['g|h']),
88+
("/i\\j", ['i\j']),
89+
("/k\"l", ['k"l']),
90+
("/ ", [' ']),
91+
("/m~0n", ['m~n']),
92+
('/\xee', ['\xee']),
93+
]
94+
for path in paths:
95+
ptr = JsonPointer(path[0])
96+
self.assertEqual(ptr.get_parts(), path[1])
97+
7798

7899
class ComparisonTests(unittest.TestCase):
79100

0 commit comments

Comments
 (0)