diff options
author | Stefan Kögl <stefan@skoegl.net> | 2013-01-06 10:57:13 +0100 |
---|---|---|
committer | Stefan Kögl <stefan@skoegl.net> | 2013-01-06 10:57:13 +0100 |
commit | 55198aa4cb5c7d3d503e8cb9e717433688af8d8f (patch) | |
tree | 03d56d54d64ce83a71f561ffa1eec0340691ce0e /tests.py | |
parent | 2537956503ea982f0fa29f54399677605a60218d (diff) | |
download | python-json-pointer-55198aa4cb5c7d3d503e8cb9e717433688af8d8f.tar.gz |
unambiguous array indices make pointers comparable
Diffstat (limited to 'tests.py')
-rwxr-xr-x | tests.py | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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]) |