Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import copy
import doctest
import unittest
from collections import OrderedDict

import jsonpointer
from jsonpointer import resolve_pointer, EndOfList, JsonPointerException, \
Expand Down Expand Up @@ -216,6 +217,24 @@ def test_trailing_escape(self):
def test_invalid_escape(self):
self.assertRaises(JsonPointerException, JsonPointer, '/foo/bar~2')

def test_ordereddict_member_not_found(self):
# Resolving a pointer to a non-existent key in an OrderedDict should
# raise JsonPointerException (not a bare KeyError or any other exception)
doc = OrderedDict([
('$schema', 'http://json-schema.org/draft-07/schema#'),
('$id', '/sports_field'),
('title', 'Field'),
('description', 'A sports field description.'),
('type', 'object'),
('properties', OrderedDict([
('description', OrderedDict([
('description', 'Field description'),
('type', 'string'),
])),
])),
])
self.assertRaises(JsonPointerException, resolve_pointer, doc, '/src')


class ToLastTests(unittest.TestCase):

Expand Down