forked from dpath-maintainers/dpath-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_path_paths.py
More file actions
38 lines (29 loc) · 769 Bytes
/
test_path_paths.py
File metadata and controls
38 lines (29 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from nose2.tools.such import helper
import dpath.segments
import dpath.exceptions
import dpath.options
def test_path_paths_empty_key_disallowed():
tdict = {
"Empty": {
"": {
"Key": ""
}
}
}
with helper.assertRaises(dpath.exceptions.InvalidKeyName):
for x in dpath.segments.walk(tdict):
pass
def test_path_paths_empty_key_allowed():
tdict = {
"Empty": {
"": {
"Key": ""
}
}
}
segments = []
dpath.options.ALLOW_EMPTY_STRING_KEYS = True
for segments, value in dpath.segments.leaves(tdict):
pass
dpath.options.ALLOW_EMPTY_STRING_KEYS = False
assert "/".join(segments) == "Empty//Key"