summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py21
1 files changed, 16 insertions, 5 deletions
diff --git a/tests.py b/tests.py
index 246b507..21483eb 100755
--- a/tests.py
+++ b/tests.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
import doctest
import unittest
import sys
@@ -62,6 +64,7 @@ class SpecificationTests(unittest.TestCase):
"/k\"l",
"/ ",
"/m~0n",
+ '/\xee',
]
for path in paths:
ptr = JsonPointer(path)
@@ -74,6 +77,11 @@ class SpecificationTests(unittest.TestCase):
class ComparisonTests(unittest.TestCase):
+ def setUp(self):
+ self.ptr1 = JsonPointer("/a/b/c")
+ self.ptr2 = JsonPointer("/a/b")
+ self.ptr3 = JsonPointer("/b/c")
+
def test_eq_hash(self):
p1 = JsonPointer("/something/1/b")
p2 = JsonPointer("/something/1/b")
@@ -91,13 +99,16 @@ class ComparisonTests(unittest.TestCase):
self.assertFalse(p1 == "/something/1/b")
def test_contains(self):
- p1 = JsonPointer("/a/b/c")
- p2 = JsonPointer("/a/b")
- p3 = JsonPointer("/b/c")
- self.assertTrue(p1.contains(p2))
- self.assertFalse(p1.contains(p3))
+ self.assertTrue(self.ptr1.contains(self.ptr2))
+ self.assertTrue(self.ptr1.contains(self.ptr1))
+ self.assertFalse(self.ptr1.contains(self.ptr3))
+
+ def test_contains_magic(self):
+ self.assertTrue(self.ptr2 in self.ptr1)
+ self.assertTrue(self.ptr1 in self.ptr1)
+ self.assertFalse(self.ptr3 in self.ptr1)
class WrongInputTests(unittest.TestCase):