Verify that __attrs_pre_init__ gets called with extra kwargs only if defined.
(self)
| 774 | |
| 775 | @pytest.mark.usefixtures("with_and_without_validation") |
| 776 | def test_pre_init_kwargs_only(self): |
| 777 | """ |
| 778 | Verify that __attrs_pre_init__ gets called with extra kwargs only if |
| 779 | defined. |
| 780 | """ |
| 781 | |
| 782 | @attr.s |
| 783 | class C: |
| 784 | y = attr.field(kw_only=True) |
| 785 | |
| 786 | def __attrs_pre_init__(self2, y): |
| 787 | self2.z = y + 1 |
| 788 | |
| 789 | c = C(y=11) |
| 790 | |
| 791 | assert 12 == getattr(c, "z", None) |
| 792 | |
| 793 | @pytest.mark.usefixtures("with_and_without_validation") |
| 794 | def test_pre_init_kw_only_work_with_defaults(self): |