Move factory tests where they belong

This commit is contained in:
Hynek Schlawack 2024-03-17 09:15:36 +01:00
parent 189ab7f806
commit 1967be0eb6
No known key found for this signature in database
2 changed files with 23 additions and 23 deletions

View File

@ -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

View File

@ -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.