# 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 decimal import Decimal
from decimal import ROUND_UP
from tests.common import DummyPostData
from wtforms import Form
from wtforms.fields import DecimalField
from wtforms.utils import unset_value
import pytest
            DecimalField(
                use_locale=True,
                name="a",
                _form=form,
                _translations=form.meta.get_translations(form),
                **kw
            )

        with pytest.raises(TypeError):
            build(places=2)

        with pytest.raises(TypeError):
            build(rounding=ROUND_UP)

    def test_formatting(self):
        val = Decimal("123456.789")
        neg = Decimal("-5.2")
        self._format_test("1,23,456.789", val)
        self._format_test("-12,52,378.2", "-1252378.2")
        self._format_test("123,456.789", val, ["en_US"])
        self._format_test("-5.2", neg, ["en_US"])
        self._format_test("123.456,789", val, ["es_ES"])
        self._format_test("123.456,789", val, ["de_DE"])
        self._format_test("-5,2", neg, ["de_DE"])
        self._format_test("-12’345.2", "-12345.2", ["de_CH"])

    def _parse_test(self, raw_val, expected, locales=unset_value):
        meta = None
        if locales is not unset_value:
            meta = {"locales": locales}

# 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/test_locale_babel.py
from decimal import Decimal
from decimal import ROUND_UP
from tests.common import DummyPostData
from wtforms import Form
from wtforms.fields import DecimalField
from wtforms.utils import unset_value
import pytest

            DecimalField(
                use_locale=True,
                name="a",
                _form=form,
                _translations=form.meta.get_translations(form),
                **kw
            )

        with pytest.raises(TypeError):
            build(places=2)

        with pytest.raises(TypeError):
            build(rounding=ROUND_UP)

    def test_formatting(self):
        val = Decimal("123456.789")
        neg = Decimal("-5.2")
        self._format_test("1,23,456.789", val)
        self._format_test("-12,52,378.2", "-1252378.2")
        self._format_test("123,456.789", val, ["en_US"])
        self._format_test("-5.2", neg, ["en_US"])
        self._format_test("123.456,789", val, ["es_ES"])
        self._format_test("123.456,789", val, ["de_DE"])
        self._format_test("-5,2", neg, ["de_DE"])
        self._format_test("-12’345.2", "-12345.2", ["de_CH"])

    def _parse_test(self, raw_val, expected, locales=unset_value):
        meta = None
        if locales is not unset_value:
            meta = {"locales": locales}

        form = self.F(DummyPostData(a=raw_val), meta=meta)