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


import pytest
from tests.common import DummyPostData
from wtforms import validators
from wtforms import widgets
from wtforms.fields import SelectField
from wtforms.form import Form
    assert f1.items.choices == [("a", "a")]
    assert f2.items.choices == [("b", "b")]
    assert f1.items.choices is not f2.items.choices


class F(Form):
    a = SelectField(choices=[("a", "hello"), ("btest", "bye")], default="a")
    b = SelectField(
        choices=[(1, "Item 1"), (2, "Item 2")],
        coerce=int,
        option_widget=widgets.TextInput(),
    )


def test_defaults():
    form = F()
    assert form.a.data == "a"
    assert form.b.data is None
    assert form.validate() is False
    assert form.a() == (
        '<select id="a" name="a"><option selected value="a">hello</option>'
        '<option value="btest">bye</option></select>'
    )
    assert form.b() == (
        '<select id="b" name="b"><option value="1">Item 1</option>'
        '<option value="2">Item 2</option></select>'
    )


def test_with_data():

# 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_select.py
import pytest
from tests.common import DummyPostData
from wtforms import validators
from wtforms import widgets
from wtforms.fields import SelectField
from wtforms.form import Form

    assert f1.items.choices == [("a", "a")]
    assert f2.items.choices == [("b", "b")]
    assert f1.items.choices is not f2.items.choices


class F(Form):
    a = SelectField(choices=[("a", "hello"), ("btest", "bye")], default="a")
    b = SelectField(
        choices=[(1, "Item 1"), (2, "Item 2")],
        coerce=int,
        option_widget=widgets.TextInput(),
    )


def test_defaults():
    form = F()
    assert form.a.data == "a"
    assert form.b.data is None
    assert form.validate() is False
    assert form.a() == (
        '<select id="a" name="a"><option selected value="a">hello</option>'
        '<option value="btest">bye</option></select>'
    )
    assert form.b() == (
        '<select id="b" name="b"><option value="1">Item 1</option>'
        '<option value="2">Item 2</option></select>'
    )


def test_with_data():

    form = F(DummyPostData(a=["btest"]))