summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2014-03-30 10:49:03 +0200
committerStefan Kögl <stefan@skoegl.net>2014-03-30 10:49:03 +0200
commitb94324408a73a2cdedefcb324a87a45f2e9baebf (patch)
treef6a1fbcd64e90b7ca81e4ea6b9acacab16c9712c /tests.py
parentac7c86e1bc35ba3e22bf5e68945d2c9316b754f9 (diff)
parent85620b0255b0680ce35c6a1b37385d054cfc99d4 (diff)
downloadpython-json-pointer-b94324408a73a2cdedefcb324a87a45f2e9baebf.tar.gz
Merge pull request #7 from alexsdutton/patch-1
JsonPointer.from_parts should handle the empty path
Diffstat (limited to 'tests.py')
-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):