summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorkafkaf- <thekafkaf@gmail.com>2014-11-10 22:15:26 +0200
committerStefan Kögl <stefan@skoegl.net>2014-11-14 21:00:17 +0100
commitd3966dd34c681a5e1c790ca212a020d83bca26ac (patch)
tree88f82cb41f6e4b0be542c03c06142a5c808d6b1f /tests.py
parent490c7a25147b0674fc0234d0462726595bd4fd87 (diff)
downloadpython-json-pointer-d3966dd34c681a5e1c790ca212a020d83bca26ac.tar.gz
Fix contains unexpected false return
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests.py b/tests.py
index 2b5608e..44447da 100755
--- a/tests.py
+++ b/tests.py
@@ -72,6 +72,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")
@@ -89,13 +94,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):