Move factory tests where they belong
This commit is contained in:
parent
189ab7f806
commit
1967be0eb6
|
@ -836,6 +836,29 @@ class TestAddInit:
|
|||
assert [] == i.a
|
||||
assert isinstance(i.b, D)
|
||||
|
||||
def test_factory_takes_self(self):
|
||||
"""
|
||||
If takes_self on factories is True, self is passed.
|
||||
"""
|
||||
C = make_class(
|
||||
"C",
|
||||
{
|
||||
"x": attr.ib(
|
||||
default=Factory((lambda self: self), takes_self=True)
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
i = C()
|
||||
|
||||
assert i is i.x
|
||||
|
||||
def test_factory_hashable(self):
|
||||
"""
|
||||
Factory is hashable.
|
||||
"""
|
||||
assert hash(Factory(None, False)) == hash(Factory(None, False))
|
||||
|
||||
def test_validator(self):
|
||||
"""
|
||||
If a validator is passed, call it with the preliminary instance, the
|
||||
|
|
|
@ -1336,29 +1336,6 @@ class TestConverter:
|
|||
assert c.x == val + 1
|
||||
assert c.y == 2
|
||||
|
||||
def test_factory_takes_self(self):
|
||||
"""
|
||||
If takes_self on factories is True, self is passed.
|
||||
"""
|
||||
C = make_class(
|
||||
"C",
|
||||
{
|
||||
"x": attr.ib(
|
||||
default=Factory((lambda self: self), takes_self=True)
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
i = C()
|
||||
|
||||
assert i is i.x
|
||||
|
||||
def test_factory_hashable(self):
|
||||
"""
|
||||
Factory is hashable.
|
||||
"""
|
||||
assert hash(Factory(None, False)) == hash(Factory(None, False))
|
||||
|
||||
def test_convert_before_validate(self):
|
||||
"""
|
||||
Validation happens after conversion.
|
||||
|
|
Loading…
Reference in New Issue