import pytest
from hypothesis import given
from hypothesis.strategies import lists, integers, floats, text, one_of, dictionaries

from datatyping.datatyping import validate


def test_empty():
    assert validate([], []) is None


@given(li=lists(integers()))
def test_plain(li):
    assert validate([int], li) is None


@given(lst=lists(one_of(floats(), text()), min_size=1))
def test_plain_typeerror(lst):
    with pytest.raises(TypeError):
        validate([int], lst)


def test_list_lengths():
    with pytest.raises(ValueError):
        validate([int, int, int, str], [1, 2, 3, 'a', 'a'])


@given(li=lists(integers(), max_size=1))
def test_list_too_short_same_type(li):
    with pytest.raises(ValueError):
        validate([int, int], li)


@given(li=lists(integers(), min_size=3))
def test_list_too_long_same_type(li):
    with pytest.raises(ValueError):
        validate([int, int], li)


def test_dict_empty():
    assert validate([dict], [{}, {}, {}]) is None


@given(i=integers())
def test_dict_strict(i):
    assert validate([{'a': int}], [{'a': i}, {'a': 456}]) is None


@given(lists(dictionaries(one_of(integers(), text()), one_of(integers(), text()))))
def test_any_dict(d):
    assert validate([dict], d) is None


def test_dict_nested():
    assert validate([{'a': {'b': [dict]}}],
                    [
                        {'a': {'b': [{}, {}]}},
                        {'a': {'b': [{'any': 'key'}, {'used': 'here'}]}},
    ]) is None

@@ -121,16 +121,42 @@
 ionaries
+, %5C%0A    fixed_dictionaries
 %0A%0Afrom d
@@ -361,31 +361,15 @@
 sts(
-one_of(floats(), text()
+floats(
 ), m
@@ -399,16 +399,17 @@
 ain_type
+_
 error(ls
@@ -482,141 +482,75 @@
 )%0A%0A%0A
-def test_list_lengths():%0A    with pytest.raises(ValueError):%0A        validate(%5Bint, int, int, str%5D, %5B1, 2, 3, 'a', 'a'%5D)%0A%0A%0A@given(li=
+@given(lst=one_of(lists(integers(), min_size=5),%0A                  
 list
@@ -568,25 +568,26 @@
 ), max_size=
-1
+3)
 ))%0Adef test_
@@ -595,30 +595,19 @@
 ist_
-too_short_same_type(li
+lengths(lst
 ):%0A 
@@ -663,29 +663,40 @@
 te(%5Bint, int
+, int, str
 %5D, l
-i
+st
 )%0A%0A%0A@given(l
@@ -699,149 +699,43 @@
 en(l
-i
+st
 =lists(
-integers(), min
+dictionaries(max
 _size=
-3))%0Adef test_list_too_long_same_type(li):%0A    with pytest.raises(ValueError):%0A        validate(%5Bint, int%5D, li)%0A%0A
+0)))
 %0Adef
@@ -743,32 +743,35 @@
 test_dict_empty(
+lst
 ):%0A    assert va
@@ -789,20 +789,11 @@
 t%5D, 
-%5B%7B%7D, %7B%7D, %7B%7D%5D
+lst
 ) is
@@ -807,18 +807,51 @@
 %0A@given(
-i=
+lst=lists(fixed_dictionaries(%7B'a': 
 integers
@@ -852,16 +852,19 @@
 tegers()
+%7D))
 )%0Adef te
@@ -878,17 +878,19 @@
 _strict(
-i
+lst
 ):%0A    a
@@ -922,30 +922,11 @@
 %7D%5D, 
-%5B%7B'a': i%7D, %7B'a': 456%7D%5D
+lst
 ) is

Rewrite list_struct tests with hypothesis