Verify that __attrs_pre_init__ gets called with extra args and kwargs if defined.
(self)
| 755 | |
| 756 | @pytest.mark.usefixtures("with_and_without_validation") |
| 757 | def test_pre_init_kwargs(self): |
| 758 | """ |
| 759 | Verify that __attrs_pre_init__ gets called with extra args and kwargs |
| 760 | if defined. |
| 761 | """ |
| 762 | |
| 763 | @attr.s |
| 764 | class C: |
| 765 | x = attr.ib() |
| 766 | y = attr.field(kw_only=True) |
| 767 | |
| 768 | def __attrs_pre_init__(self2, x, y): |
| 769 | self2.z = x + y + 1 |
| 770 | |
| 771 | c = C(10, y=11) |
| 772 | |
| 773 | assert 22 == getattr(c, "z", None) |
| 774 | |
| 775 | @pytest.mark.usefixtures("with_and_without_validation") |
| 776 | def test_pre_init_kwargs_only(self): |