Property tests for attributes with converter, and a factory default.
(self, val, init)
| 1741 | |
| 1742 | @given(integers(), booleans()) |
| 1743 | def test_converter_factory_property(self, val, init): |
| 1744 | """ |
| 1745 | Property tests for attributes with converter, and a factory default. |
| 1746 | """ |
| 1747 | C = make_class( |
| 1748 | "C", |
| 1749 | { |
| 1750 | "y": attr.ib(), |
| 1751 | "x": attr.ib( |
| 1752 | init=init, |
| 1753 | default=Factory(lambda: val), |
| 1754 | converter=lambda v: v + 1, |
| 1755 | ), |
| 1756 | }, |
| 1757 | ) |
| 1758 | c = C(2) |
| 1759 | |
| 1760 | assert c.x == val + 1 |
| 1761 | assert c.y == 2 |
| 1762 | |
| 1763 | def test_convert_before_validate(self): |
| 1764 | """ |
nothing calls this directly
no test coverage detected