Esempio n. 1
0
from attr._compat import PY2, ordered_dict
from attr._make import (
    Attribute, Factory, _AndValidator, _Attributes, _ClassBuilder,
    _CountingAttr, _transform_attrs, and_, fields, fields_dict, make_class,
    validate
)
from attr.exceptions import DefaultAlreadySetError, NotAnAttrsClassError

from .strategies import (
    gen_attr_names, list_of_attrs, simple_attrs, simple_attrs_with_metadata,
    simple_attrs_without_metadata, simple_classes
)
from .utils import simple_attr


attrs_st = simple_attrs.map(lambda c: Attribute.from_counting_attr("name", c))


class TestCountingAttr(object):
    """
    Tests for `attr`.
    """
    def test_returns_Attr(self):
        """
        Returns an instance of _CountingAttr.
        """
        a = attr.ib()

        assert isinstance(a, _CountingAttr)

    def test_validators_lists_to_wrapped_tuples(self):
Esempio n. 2
0
    NotAnAttrsClassError,
    PythonTooOldError,
)

from .strategies import (
    gen_attr_names,
    list_of_attrs,
    simple_attrs,
    simple_attrs_with_metadata,
    simple_attrs_without_metadata,
    simple_classes,
)
from .utils import simple_attr


attrs_st = simple_attrs.map(lambda c: Attribute.from_counting_attr("name", c))


class TestCountingAttr(object):
    """
    Tests for `attr`.
    """

    def test_returns_Attr(self):
        """
        Returns an instance of _CountingAttr.
        """
        a = attr.ib()

        assert isinstance(a, _CountingAttr)
Esempio n. 3
0
from attr import _config
from attr._compat import PY2
from attr._make import (
    Attribute,
    _CountingAttr,
    _transform_attrs,
    attr,
    attributes,
    fields,
    make_class,
    validate,
)

from .utils import simple_attr, simple_attrs

attrs = simple_attrs.map(lambda c: Attribute.from_counting_attr('name', c))


class TestCountingAttr(object):
    """
    Tests for `attr`.
    """
    def test_returns_Attr(self):
        """
        Returns an instance of _CountingAttr.
        """
        a = attr()
        assert isinstance(a, _CountingAttr)


def make_tc():