summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2013-01-06 10:57:13 +0100
committerStefan Kögl <stefan@skoegl.net>2013-01-06 10:57:13 +0100
commit55198aa4cb5c7d3d503e8cb9e717433688af8d8f (patch)
tree03d56d54d64ce83a71f561ffa1eec0340691ce0e /tests.py
parent2537956503ea982f0fa29f54399677605a60218d (diff)
downloadpython-json-pointer-55198aa4cb5c7d3d503e8cb9e717433688af8d8f.tar.gz
unambiguous array indices make pointers comparable
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests.py b/tests.py
index 2d9c8bc..5f15a25 100755
--- a/tests.py
+++ b/tests.py
@@ -4,7 +4,8 @@
import doctest
import unittest
import sys
-from jsonpointer import resolve_pointer, EndOfList, JsonPointerException
+from jsonpointer import resolve_pointer, EndOfList, JsonPointerException, \
+ JsonPointer
class SpecificationTests(unittest.TestCase):
""" Tests all examples from the JSON Pointer specification """
@@ -46,12 +47,30 @@ class SpecificationTests(unittest.TestCase):
self.assertRaises(JsonPointerException, resolve_pointer, doc, "/foo/-/1")
+class ComparisonTests(unittest.TestCase):
+
+ def test_eq_hash(self):
+ p1 = JsonPointer("/something/1/b")
+ p2 = JsonPointer("/something/1/b")
+ p3 = JsonPointer("/something/1.0/b")
+
+ self.assertEqual(p1, p2)
+ self.assertNotEqual(p1, p3)
+ self.assertNotEqual(p2, p3)
+
+ self.assertEqual(hash(p1), hash(p2))
+ self.assertNotEqual(hash(p1), hash(p3))
+ self.assertNotEqual(hash(p2), hash(p3))
+
+
+
modules = ['jsonpointer']
coverage_modules = []
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SpecificationTests))
+suite.addTest(unittest.makeSuite(ComparisonTests))
for module in modules:
m = __import__(module, fromlist=[module])