# Path: tests/common.py
# class DummyPostData(dict):
#     def getlist(self, key):
#         v = self[key]
#         if not isinstance(v, (list, tuple)):
#             v = [v]
#         return v


from collections import namedtuple
from tests.common import DummyPostData
from wtforms import validators
from wtforms.fields import FieldList
from wtforms.fields import FormField
from wtforms.fields import StringField
from wtforms.form import Form
import pytest




class AttrDict:
    def __init__(self, *args, **kw):
        self.__dict__.update(*args, **kw)


def make_form(name="F", **fields):
    return type(str(name), (Form,), fields)


t = StringField(validators=[validators.DataRequired()])


def test_form():
    F = make_form(a=FieldList(t))
    data = ["foo", "hi", "rawr"]
    a = F(a=data).a
    assert a.entries[1].data == "hi"
    assert a.entries[1].name == "a-1"
    assert a.data == data
    assert len(a.entries) == 3


# Path: tests/common.py
# class DummyPostData(dict):
#     def getlist(self, key):
#         v = self[key]
#         if not isinstance(v, (list, tuple)):
#             v = [v]
#         return v


# Path: tests/fields/test_list.py
from collections import namedtuple
from tests.common import DummyPostData
from wtforms import validators
from wtforms.fields import FieldList
from wtforms.fields import FormField
from wtforms.fields import StringField
from wtforms.form import Form
import pytest





class AttrDict:
    def __init__(self, *args, **kw):
        self.__dict__.update(*args, **kw)


def make_form(name="F", **fields):
    return type(str(name), (Form,), fields)


t = StringField(validators=[validators.DataRequired()])


def test_form():
    F = make_form(a=FieldList(t))
    data = ["foo", "hi", "rawr"]
    a = F(a=data).a
    assert a.entries[1].data == "hi"
    assert a.entries[1].name == "a-1"
    assert a.data == data
    assert len(a.entries) == 3


    pdata = DummyPostData(