def test_heavy_nested(lst): assert validate([[int], float, [[float]]], lst) is None with pytest.raises(TypeError): validate([[str], int, int], lst) with pytest.raises(TypeError): validate([[[float]]], lst)
def test_different_sequences(lst, tpl): with pytest.raises(TypeError): if tpl: validate([int], tpl) else: validate([], tpl) with pytest.raises(TypeError): if lst: validate((int), lst) else: validate((), lst)
def test_advanced(dct): structure = { 'total_count': int, 'active': bool, 'people': [{ 'id': int, 'title': str, 'salary': float, }], 'timestamps': [int], } assert validate(structure, dct) is None
def test_plain_no_strict(dct): assert validate({'a': str}, dct, strict=False) is None
def test_simple_error(not_string): with pytest.raises(TypeError): validate(str, not_string)
def test_list_lengths(lst): with pytest.raises(ValueError): validate([int, int, int, str], lst)
def test_plain(li): assert validate([int], li) is None
def test_plain_type_error(tpl): with pytest.raises(TypeError): validate((int, ), tpl)
def test_dict_nested(lst): assert validate([{'a': {'b': [dict]}}], lst) is None
def test_simple_pos_int(num): assert validate(positive_int, num) is None
def test_deep_nesting(data): type_mask = [two_item_list, [positive_int, two_item_list], [title]] assert validate(type_mask, data) is None
def test_empty(): assert validate({}, {}) is None
def test_nested_dict(dct): assert validate({'a': {'b': int}}, dct) is None
def test_strict(dct): assume(len(dct) > 1) with pytest.raises(KeyError): validate({'a': str}, dct)
def test_plain_no_strict_error(dct): with pytest.raises(KeyError): validate({'a': str, 'b': float}, dct, strict=False)
def test_simple_title(words): assert validate(title, words) is None
def test_different_mappings(dct): with pytest.raises(TypeError): validate(dict, OrderedDict(dct)) validate(OrderedDict, dct)
def test_simple_ti_list(lst): assert validate(two_item_list, lst) is None
def test_plain(tpl): assert validate((int, ), tpl) is None
def test_simple_pos_int_error(num): with pytest.raises(TypeError): validate(positive_int, num)
def test_list_lengths(tpl): with pytest.raises(ValueError): validate((int, int, int, str), tpl)
def test_simple_title_error(words): assume(len(words) > 0) assume(not words.isspace()) with pytest.raises(TypeError): validate(title, words)
def test_plain_type_error(lst): with pytest.raises(TypeError): validate([int], lst)
def test_simple_ti_list_error(lst): with pytest.raises(TypeError): validate(two_item_list, lst)
def test_nested(lst): assert validate([[int]], lst) is None with pytest.raises(TypeError): validate([int], lst)
def test_nested(data): type_mask = [{'id': positive_int, 'name': title}] assert validate(type_mask, data) is None
def test_empty(): assert validate([], []) is None
def test_nested_error(data): assume(len(data) != 0) type_mask = [{'id': positive_int, 'name': title}] with pytest.raises(TypeError): validate(type_mask, data)
def test_simple(string): assert validate(str, string) is None
def test_plain_key_error(dct): with pytest.raises(KeyError): validate({'a': str, 'b': float}, dct)