Skip to content

Commit 1c8fa84

Browse files
committed
Remove references to dpath.util in tests
1 parent 6460b64 commit 1c8fa84

File tree

12 files changed

+128
-129
lines changed

12 files changed

+128
-129
lines changed

dpath/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def f(_, pair, results):
186186

187187
raise KeyError(glob)
188188
elif len(results) > 1:
189-
raise ValueError(f"dpath.util.get() globs must match only one leaf: {glob}")
189+
raise ValueError(f"dpath.get() globs must match only one leaf: {glob}")
190190

191191
return results[0]
192192

dpath/util.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import warnings
2-
from typing import Any, Dict
32

43
import dpath
54
from dpath import _DEFAULT_SENTINEL
6-
from dpath.types import Filter, Creator, MergeType
5+
from dpath.types import MergeType
76

87

98
def deprecated(func):
@@ -18,35 +17,35 @@ def wrapper(*args, **kwargs):
1817

1918

2019
@deprecated
21-
def new(obj: Dict, path: str, value, separator="/", creator: Creator = None) -> Dict:
20+
def new(obj, path, value, separator="/", creator=None):
2221
return dpath.new(obj, path, value, separator, creator)
2322

2423

2524
@deprecated
26-
def delete(obj: Dict, glob: str, separator="/", afilter: Filter = None) -> int:
25+
def delete(obj, glob, separator="/", afilter=None):
2726
return dpath.delete(obj, glob, separator, afilter)
2827

2928

3029
@deprecated
31-
def set(obj: Dict, glob: str, value, separator="/", afilter: Filter = None) -> int:
30+
def set(obj, glob, value, separator="/", afilter=None):
3231
return dpath.set(obj, glob, value, separator, afilter)
3332

3433

3534
@deprecated
36-
def get(obj: Dict, glob: str, separator="/", default: Any = _DEFAULT_SENTINEL) -> Dict:
35+
def get(obj, glob, separator="/", default=_DEFAULT_SENTINEL):
3736
return dpath.get(obj, glob, separator, default)
3837

3938

4039
@deprecated
41-
def values(obj: Dict, glob: str, separator="/", afilter: Filter = None, dirs=True):
40+
def values(obj, glob, separator="/", afilter=None, dirs=True):
4241
return dpath.values(obj, glob, separator, afilter, dirs)
4342

4443

4544
@deprecated
46-
def search(obj: Dict, glob: str, yielded=False, separator="/", afilter: Filter = None, dirs=True):
45+
def search(obj, glob, yielded=False, separator="/", afilter = None, dirs=True):
4746
return dpath.search(obj, glob, yielded, separator, afilter, dirs)
4847

4948

5049
@deprecated
51-
def merge(dst: Dict, src: Dict, separator="/", afilter: Filter = None, flags=MergeType.ADDITIVE):
50+
def merge(dst, src, separator="/", afilter=None, flags=MergeType.ADDITIVE):
5251
return dpath.merge(dst, src, separator, afilter, flags),

tests/test_broken_afilter.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import dpath.util
1+
import dpath
22
import sys
33

44

@@ -25,15 +25,15 @@ def afilter(x):
2525
'a/b/c/f',
2626
]
2727

28-
for (path, value) in dpath.util.search(dict, '/**', yielded=True, afilter=afilter):
28+
for (path, value) in dpath.search(dict, '/**', yielded=True, afilter=afilter):
2929
assert path in paths
30-
assert "view_failure" not in dpath.util.search(dict, '/**', afilter=afilter)['a']
31-
assert "d" not in dpath.util.search(dict, '/**', afilter=afilter)['a']['b']['c']
30+
assert "view_failure" not in dpath.search(dict, '/**', afilter=afilter)['a']
31+
assert "d" not in dpath.search(dict, '/**', afilter=afilter)['a']['b']['c']
3232

33-
for (path, value) in dpath.util.search(dict, ['**'], yielded=True, afilter=afilter):
33+
for (path, value) in dpath.search(dict, ['**'], yielded=True, afilter=afilter):
3434
assert path in paths
35-
assert "view_failure" not in dpath.util.search(dict, ['**'], afilter=afilter)['a']
36-
assert "d" not in dpath.util.search(dict, ['**'], afilter=afilter)['a']['b']['c']
35+
assert "view_failure" not in dpath.search(dict, ['**'], afilter=afilter)['a']
36+
assert "d" not in dpath.search(dict, ['**'], afilter=afilter)['a']['b']['c']
3737

3838
def filter(x):
3939
sys.stderr.write(str(x))
@@ -52,7 +52,7 @@ def filter(x):
5252
],
5353
}
5454

55-
results = [[x[0], x[1]] for x in dpath.util.search(a, 'actions/*', yielded=True)]
56-
results = [[x[0], x[1]] for x in dpath.util.search(a, 'actions/*', afilter=filter, yielded=True)]
55+
results = [[x[0], x[1]] for x in dpath.search(a, 'actions/*', yielded=True)]
56+
results = [[x[0], x[1]] for x in dpath.search(a, 'actions/*', afilter=filter, yielded=True)]
5757
assert len(results) == 1
5858
assert results[0][1]['type'] == 'correct'
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from nose2.tools.such import helper
22

3-
import dpath.util
3+
import dpath
44
import dpath.exceptions
55

66

@@ -11,7 +11,7 @@ def test_delete_separator():
1111
},
1212
}
1313

14-
dpath.util.delete(dict, ';a;b', separator=";")
14+
dpath.delete(dict, ';a;b', separator=";")
1515
assert 'b' not in dict['a']
1616

1717

@@ -22,7 +22,7 @@ def test_delete_existing():
2222
},
2323
}
2424

25-
dpath.util.delete(dict, '/a/b')
25+
dpath.delete(dict, '/a/b')
2626
assert 'b' not in dict['a']
2727

2828

@@ -33,7 +33,7 @@ def test_delete_missing():
3333
}
3434

3535
with helper.assertRaises(dpath.exceptions.PathNotFound):
36-
dpath.util.delete(dict, '/a/b')
36+
dpath.delete(dict, '/a/b')
3737

3838

3939
def test_delete_filter():
@@ -50,7 +50,7 @@ def afilter(x):
5050
},
5151
}
5252

53-
dpath.util.delete(dict, '/a/*', afilter=afilter)
53+
dpath.delete(dict, '/a/*', afilter=afilter)
5454
assert dict['a']['b'] == 0
5555
assert dict['a']['c'] == 1
5656
assert 'd' not in dict['a']
Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
import mock
66
from nose2.tools.such import helper
77

8-
import dpath.util
8+
import dpath
99

1010

1111
def test_util_get_root():
1212
x = {'p': {'a': {'t': {'h': 'value'}}}}
1313

14-
ret = dpath.util.get(x, '/p/a/t/h')
14+
ret = dpath.get(x, '/p/a/t/h')
1515
assert ret == 'value'
1616

17-
ret = dpath.util.get(x, '/')
17+
ret = dpath.get(x, '/')
1818
assert ret == x
1919

2020

@@ -31,11 +31,11 @@ def test_get_explicit_single():
3131
},
3232
}
3333

34-
assert dpath.util.get(ehash, '/a/b/c/f') == 2
35-
assert dpath.util.get(ehash, ['a', 'b', 'c', 'f']) == 2
36-
assert dpath.util.get(ehash, ['a', 'b', 'c', 'f'], default=5) == 2
37-
assert dpath.util.get(ehash, ['does', 'not', 'exist'], default=None) is None
38-
assert dpath.util.get(ehash, ['doesnt', 'exist'], default=5) == 5
34+
assert dpath.get(ehash, '/a/b/c/f') == 2
35+
assert dpath.get(ehash, ['a', 'b', 'c', 'f']) == 2
36+
assert dpath.get(ehash, ['a', 'b', 'c', 'f'], default=5) == 2
37+
assert dpath.get(ehash, ['does', 'not', 'exist'], default=None) is None
38+
assert dpath.get(ehash, ['doesnt', 'exist'], default=5) == 5
3939

4040

4141
def test_get_glob_single():
@@ -51,10 +51,10 @@ def test_get_glob_single():
5151
},
5252
}
5353

54-
assert dpath.util.get(ehash, '/a/b/*/f') == 2
55-
assert dpath.util.get(ehash, ['a', 'b', '*', 'f']) == 2
56-
assert dpath.util.get(ehash, ['a', 'b', '*', 'f'], default=5) == 2
57-
assert dpath.util.get(ehash, ['doesnt', '*', 'exist'], default=6) == 6
54+
assert dpath.get(ehash, '/a/b/*/f') == 2
55+
assert dpath.get(ehash, ['a', 'b', '*', 'f']) == 2
56+
assert dpath.get(ehash, ['a', 'b', '*', 'f'], default=5) == 2
57+
assert dpath.get(ehash, ['doesnt', '*', 'exist'], default=6) == 6
5858

5959

6060
def test_get_glob_multiple():
@@ -71,16 +71,16 @@ def test_get_glob_multiple():
7171
},
7272
}
7373

74-
helper.assertRaises(ValueError, dpath.util.get, ehash, '/a/b/*/d')
75-
helper.assertRaises(ValueError, dpath.util.get, ehash, ['a', 'b', '*', 'd'])
76-
helper.assertRaises(ValueError, dpath.util.get, ehash, ['a', 'b', '*', 'd'], default=3)
74+
helper.assertRaises(ValueError, dpath.get, ehash, '/a/b/*/d')
75+
helper.assertRaises(ValueError, dpath.get, ehash, ['a', 'b', '*', 'd'])
76+
helper.assertRaises(ValueError, dpath.get, ehash, ['a', 'b', '*', 'd'], default=3)
7777

7878

7979
def test_get_absent():
8080
ehash = {}
8181

82-
helper.assertRaises(KeyError, dpath.util.get, ehash, '/a/b/c/d/f')
83-
helper.assertRaises(KeyError, dpath.util.get, ehash, ['a', 'b', 'c', 'd', 'f'])
82+
helper.assertRaises(KeyError, dpath.get, ehash, '/a/b/c/d/f')
83+
helper.assertRaises(KeyError, dpath.get, ehash, ['a', 'b', 'c', 'd', 'f'])
8484

8585

8686
def test_values():
@@ -96,13 +96,13 @@ def test_values():
9696
},
9797
}
9898

99-
ret = dpath.util.values(ehash, '/a/b/c/*')
99+
ret = dpath.values(ehash, '/a/b/c/*')
100100
assert isinstance(ret, list)
101101
assert 0 in ret
102102
assert 1 in ret
103103
assert 2 in ret
104104

105-
ret = dpath.util.values(ehash, ['a', 'b', 'c', '*'])
105+
ret = dpath.values(ehash, ['a', 'b', 'c', '*'])
106106
assert isinstance(ret, list)
107107
assert 0 in ret
108108
assert 1 in ret
@@ -116,17 +116,17 @@ def test_values_passes_through(searchfunc):
116116
def y():
117117
return False
118118

119-
dpath.util.values({}, '/a/b', ':', y, False)
119+
dpath.values({}, '/a/b', ':', y, False)
120120
searchfunc.assert_called_with({}, '/a/b', True, ':', y, False)
121121

122-
dpath.util.values({}, ['a', 'b'], ':', y, False)
122+
dpath.values({}, ['a', 'b'], ':', y, False)
123123
searchfunc.assert_called_with({}, ['a', 'b'], True, ':', y, False)
124124

125125

126126
def test_none_values():
127127
d = {'p': {'a': {'t': {'h': None}}}}
128128

129-
v = dpath.util.get(d, 'p/a/t/h')
129+
v = dpath.get(d, 'p/a/t/h')
130130
assert v is None
131131

132132

@@ -142,7 +142,7 @@ def test_values_list():
142142
],
143143
}
144144

145-
ret = dpath.util.values(a, 'actions/*')
145+
ret = dpath.values(a, 'actions/*')
146146
assert isinstance(ret, list)
147147
assert len(ret) == 2
148148

@@ -174,18 +174,18 @@ def func(x):
174174
}
175175

176176
# It should be possible to get the callables:
177-
assert dpath.util.get(testdict, 'a') == func
178-
assert dpath.util.get(testdict, 'b')(42) == 42
177+
assert dpath.get(testdict, 'a') == func
178+
assert dpath.get(testdict, 'b')(42) == 42
179179

180180
# It should be possible to get other values:
181-
assert dpath.util.get(testdict, 'c/0') == testdict['c'][0]
182-
assert dpath.util.get(testdict, 'd')[0] == testdict['d'][0]
183-
assert dpath.util.get(testdict, 'd/0') == testdict['d'][0]
184-
assert dpath.util.get(testdict, 'd/1') == testdict['d'][1]
185-
assert dpath.util.get(testdict, 'e') == testdict['e']
181+
assert dpath.get(testdict, 'c/0') == testdict['c'][0]
182+
assert dpath.get(testdict, 'd')[0] == testdict['d'][0]
183+
assert dpath.get(testdict, 'd/0') == testdict['d'][0]
184+
assert dpath.get(testdict, 'd/1') == testdict['d'][1]
185+
assert dpath.get(testdict, 'e') == testdict['e']
186186

187187
# Values should also still work:
188-
assert dpath.util.values(testdict, 'f/config') == ['something']
188+
assert dpath.values(testdict, 'f/config') == ['something']
189189

190190
# Data classes should also be retrievable:
191191
try:
@@ -207,4 +207,4 @@ class Connection:
207207
),
208208
}
209209

210-
assert dpath.util.search(testdict, 'g/my*')['g']['my-key'] == testdict['g']['my-key']
210+
assert dpath.search(testdict, 'g/my*')['g']['my-key'] == testdict['g']['my-key']

0 commit comments

Comments
 (0)