Changeset View
Changeset View
Standalone View
Standalone View
swh/model/tests/test_hypothesis_strategies.py
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | |||||
def assert_nested_dict(obj): | def assert_nested_dict(obj): | ||||
"""Tests the object is a nested dict and contains no more class | """Tests the object is a nested dict and contains no more class | ||||
from swh.model.model.""" | from swh.model.model.""" | ||||
if isinstance(obj, dict): | if isinstance(obj, dict): | ||||
for (key, value) in obj.items(): | for (key, value) in obj.items(): | ||||
assert isinstance(key, (str, bytes)), key | assert isinstance(key, (str, bytes)), key | ||||
assert_nested_dict(value) | assert_nested_dict(value) | ||||
elif isinstance(obj, list): | elif isinstance(obj, tuple): | ||||
for value in obj: | for value in obj: | ||||
assert_nested_dict(value) | assert_nested_dict(value) | ||||
elif isinstance(obj, (int, float, str, bytes, bool, type(None), datetime.datetime)): | elif isinstance(obj, (int, float, str, bytes, bool, type(None), datetime.datetime)): | ||||
pass | pass | ||||
else: | else: | ||||
assert False, obj | assert False, obj | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |