File: conftest.py

package info (click to toggle)
wtforms-alchemy 0.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 492 kB
  • sloc: python: 3,955; makefile: 119; sh: 11
file content (39 lines) | stat: -rw-r--r-- 995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pytest
from wtforms.form import FormMeta

from wtforms_alchemy import (
    model_form_factory,
    model_form_meta_factory,
    ModelFormMeta,
)


class _MetaWithInit(FormMeta):
    def __init__(cls, *args, **kwargs):
        cls.test_attr = "SomeVal"
        FormMeta.__init__(cls, *args, **kwargs)


MetaWithInit = model_form_meta_factory(_MetaWithInit)


class _MetaWithoutInit(FormMeta):
    test_attr = "SomeVal"


MetaWithoutInit = model_form_meta_factory(_MetaWithoutInit)


@pytest.fixture(params=[MetaWithInit, MetaWithoutInit, ModelFormMeta])
def model_form_all(request):
    """Returns one of each possible model form classes with custom and the
    original metaclass."""
    ModelForm = model_form_factory(meta=request.param)
    return ModelForm


@pytest.fixture(params=[MetaWithInit, MetaWithoutInit])
def model_form_custom(request):
    """Returns one of each possible model form classes with custom
    metaclasses."""
    return model_form_factory(meta=request.param)