summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Dutton <alexander.dutton@it.ox.ac.uk>2014-03-26 14:48:32 +0000
committerAlexander Dutton <alexander.dutton@it.ox.ac.uk>2014-03-26 14:48:32 +0000
commit1ed957b1e4ea6206f94830b30882de83b34ee935 (patch)
tree6003a3a4da59b03bd88a644d469e14e1ea60efe3
parent95a5b4672a60ecf298ea86ef501550fb0c032d52 (diff)
downloadpython-json-pointer-1ed957b1e4ea6206f94830b30882de83b34ee935.tar.gz
Added tests for round-tripping pointers from paths to parts
-rwxr-xr-xtests.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 9dc5f1b..2b5608e 100755
--- a/tests.py
+++ b/tests.py
@@ -47,6 +47,28 @@ class SpecificationTests(unittest.TestCase):
self.assertTrue(isinstance(resolve_pointer(doc, "/foo/-"), EndOfList))
self.assertRaises(JsonPointerException, resolve_pointer, doc, "/foo/-/1")
+ def test_round_trip(self):
+ paths = [
+ "",
+ "/foo",
+ "/foo/0",
+ "/",
+ "/a~1b",
+ "/c%d",
+ "/e^f",
+ "/g|h",
+ "/i\\j",
+ "/k\"l",
+ "/ ",
+ "/m~0n",
+ ]
+ for path in paths:
+ ptr = JsonPointer(path)
+ self.assertEqual(path, ptr.path)
+
+ parts = ptr.parts
+ new_ptr = JsonPointer.from_parts(parts)
+ self.assertEqual(ptr, new_ptr)
class ComparisonTests(unittest.TestCase):