|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 |
|
4 |
| -from __future__ import unicode_literals |
5 |
| - |
6 | 4 | import copy
|
7 | 5 | import doctest
|
8 |
| -import sys |
9 | 6 | import unittest
|
10 | 7 |
|
11 | 8 | import jsonpointer
|
@@ -78,45 +75,33 @@ def test_round_trip(self):
|
78 | 75 |
|
79 | 76 | def test_str_and_repr(self):
|
80 | 77 | paths = [
|
81 |
| - ("", "", "JsonPointer({u}'')"), |
82 |
| - ("/foo", "/foo", "JsonPointer({u}'/foo')"), |
83 |
| - ("/foo/0", "/foo/0", "JsonPointer({u}'/foo/0')"), |
84 |
| - ("/", "/", "JsonPointer({u}'/')"), |
85 |
| - ("/a~1b", "/a~1b", "JsonPointer({u}'/a~1b')"), |
86 |
| - ("/c%d", "/c%d", "JsonPointer({u}'/c%d')"), |
87 |
| - ("/e^f", "/e^f", "JsonPointer({u}'/e^f')"), |
88 |
| - ("/g|h", "/g|h", "JsonPointer({u}'/g|h')"), |
89 |
| - ("/i\\j", "/i\\j", "JsonPointer({u}'/i\\\\j')"), |
90 |
| - ("/k\"l", "/k\"l", "JsonPointer({u}'/k\"l')"), |
91 |
| - ("/ ", "/ ", "JsonPointer({u}'/ ')"), |
92 |
| - ("/m~0n", "/m~0n", "JsonPointer({u}'/m~0n')"), |
| 78 | + ("", "", "JsonPointer('')"), |
| 79 | + ("/foo", "/foo", "JsonPointer('/foo')"), |
| 80 | + ("/foo/0", "/foo/0", "JsonPointer('/foo/0')"), |
| 81 | + ("/", "/", "JsonPointer('/')"), |
| 82 | + ("/a~1b", "/a~1b", "JsonPointer('/a~1b')"), |
| 83 | + ("/c%d", "/c%d", "JsonPointer('/c%d')"), |
| 84 | + ("/e^f", "/e^f", "JsonPointer('/e^f')"), |
| 85 | + ("/g|h", "/g|h", "JsonPointer('/g|h')"), |
| 86 | + ("/i\\j", "/i\\j", "JsonPointer('/i\\\\j')"), |
| 87 | + ("/k\"l", "/k\"l", "JsonPointer('/k\"l')"), |
| 88 | + ("/ ", "/ ", "JsonPointer('/ ')"), |
| 89 | + ("/m~0n", "/m~0n", "JsonPointer('/m~0n')"), |
93 | 90 | ]
|
94 | 91 | for path, ptr_str, ptr_repr in paths:
|
95 | 92 | ptr = JsonPointer(path)
|
96 | 93 | self.assertEqual(path, ptr.path)
|
97 |
| - |
98 |
| - if sys.version_info[0] == 2: |
99 |
| - u_str = "u" |
100 |
| - else: |
101 |
| - u_str = "" |
102 | 94 | self.assertEqual(ptr_str, str(ptr))
|
103 |
| - self.assertEqual(ptr_repr.format(u=u_str), repr(ptr)) |
104 |
| - |
105 |
| - if sys.version_info[0] == 2: |
106 |
| - path = "/\xee" |
107 |
| - ptr_str = b"/\xee" |
108 |
| - ptr_repr = "JsonPointer(u'/\\xee')" |
109 |
| - else: |
110 |
| - path = "/\xee" |
111 |
| - ptr_str = "/\xee" |
112 |
| - ptr_repr = "JsonPointer('/\xee')" |
| 95 | + self.assertEqual(ptr_repr, repr(ptr)) |
| 96 | + |
| 97 | + path = "/\xee" |
| 98 | + ptr_str = "/\xee" |
| 99 | + ptr_repr = "JsonPointer('/\xee')" |
113 | 100 | ptr = JsonPointer(path)
|
114 | 101 | self.assertEqual(path, ptr.path)
|
115 |
| - |
116 | 102 | self.assertEqual(ptr_str, str(ptr))
|
117 | 103 | self.assertEqual(ptr_repr, repr(ptr))
|
118 | 104 |
|
119 |
| - # should not be unicode in Python 2 |
120 | 105 | self.assertIsInstance(str(ptr), str)
|
121 | 106 | self.assertIsInstance(repr(ptr), str)
|
122 | 107 |
|
|
0 commit comments