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
44 lines (41 loc) · 1004 Bytes
/
Copy pathtest_path_paths.py
File metadata and controls
44 lines (41 loc) · 1004 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
39
40
41
42
43
44
import nose
from nose.tools import raises
import dpath.path
import dpath.exceptions
import dpath.options
@raises(dpath.exceptions.InvalidKeyName)
def test_path_paths_empty_key_disallowed():
tdict = {
"Empty": {
"": {
"Key": ""
}
}
}
for x in dpath.path.paths(tdict):
pass
def test_path_paths_empty_key_allowed():
tdict = {
"Empty": {
"": {
"Key": ""
}
}
}
parts=[]
dpath.options.ALLOW_EMPTY_STRING_KEYS=True
for x in dpath.path.paths(tdict, dirs=False, leaves=True):
path = x
for x in path[:-1]:
parts.append(x[0])
dpath.options.ALLOW_EMPTY_STRING_KEYS=False
assert("/".join(parts) == "Empty//Key")
def test_path_paths_int_keys():
dpath.path.validate([
['I', dict],
['am', dict],
['path', dict],
[0, dict],
['of', dict],
[2, int]
])