|
1 | 1 | import re
|
2 | 2 | import sys
|
3 |
| -from collections import OrderedDict, defaultdict |
| 3 | +from collections import OrderedDict |
4 | 4 | from collections.abc import Mapping
|
5 | 5 | from typing import Any
|
6 | 6 |
|
@@ -343,48 +343,3 @@ def test_ordered_dict_key_order_preservation(strict):
|
343 | 343 | result2 = v.validate_python(foo2, strict=strict)
|
344 | 344 | assert list(result2.keys()) == list(foo2.keys()) == ['y', 'z', 'x']
|
345 | 345 | assert result2 == {'y': 2, 'z': 3, 'x': 1}
|
346 |
| - |
347 |
| - |
348 |
| -@skip_on_graalpy |
349 |
| -def test_userdefined_ordereddict(): |
350 |
| - class MyOD(Mapping): |
351 |
| - def __init__(self, **kwargs): |
352 |
| - self.dict = {} |
353 |
| - for kv in kwargs.items(): |
354 |
| - self.dict[kv[0]] = kv[1] |
355 |
| - |
356 |
| - def __iter__(self): |
357 |
| - return iter(self.dict.keys()) |
358 |
| - |
359 |
| - def move_to_end(self, key): |
360 |
| - self.dict[key] = self.dict.pop(key) |
361 |
| - |
362 |
| - def __getitem__(self, key): |
363 |
| - return self.dict[key] |
364 |
| - |
365 |
| - def __len__(self): |
366 |
| - return len(self.dict) |
367 |
| - |
368 |
| - v = SchemaValidator(cs.dict_schema(keys_schema=cs.str_schema(), values_schema=cs.int_schema())) |
369 |
| - |
370 |
| - foo = MyOD(**{'a': 1, 'b': 2}) |
371 |
| - foo.move_to_end('a') |
372 |
| - |
373 |
| - result = v.validate_python(foo) |
374 |
| - assert list(result.keys()) == list(foo.keys()) == ['b', 'a'] |
375 |
| - assert result == {'b': 2, 'a': 1} |
376 |
| - |
377 |
| - |
378 |
| -@pytest.mark.parametrize('strict', [True, False]) |
379 |
| -def test_defaultdict(strict): |
380 |
| - v = SchemaValidator(cs.dict_schema(keys_schema=cs.str_schema(), values_schema=cs.int_schema())) |
381 |
| - |
382 |
| - dd = defaultdict(int, {}) |
383 |
| - # simulate move to end, since defaultdict doesn't have it |
384 |
| - dd['a'] = 1 |
385 |
| - dd['b'] = 2 |
386 |
| - dd['a'] = dd.pop('a') |
387 |
| - |
388 |
| - result = v.validate_python(dd, strict=strict) |
389 |
| - assert list(result.keys()) == list(dd.keys()) == ['b', 'a'] |
390 |
| - assert result == {'b': 2, 'a': 1} |
0 commit comments