Skip to content

Commit

Permalink
Missed one monkeypatching
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Sep 29, 2023
1 parent e78782b commit efe7bbe
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tests/test_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,11 @@ def __attrs_pre_init__(self2, x, y):
assert 22 == getattr(c, "z", None)

@pytest.mark.parametrize("with_validation", [True, False])
def test_pre_init_kwargs_only(self, with_validation, monkeypatch):
def test_pre_init_kwargs_only(self, with_validation):
"""
Verify that __attrs_pre_init__ gets called with extra kwargs only if defined.
Verify that __attrs_pre_init__ gets called with extra kwargs only if
defined.
"""
monkeypatch.setattr(_config, "_run_validators", with_validation)

@attr.s
class C:
Expand All @@ -688,7 +688,11 @@ class C:
def __attrs_pre_init__(self2, y):
self2.z = y + 1

c = C(y=11)
try:
attr.validators.set_disabled(not with_validation)
c = C(y=11)
finally:
attr.validators.set_disabled(False)

assert 12 == getattr(c, "z", None)

Expand Down

0 comments on commit efe7bbe

Please sign in to comment.