Skip to content

Commit 8954a0a

Browse files
committed
more helpful messages for tests
1 parent 038f56c commit 8954a0a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/validators/test_dataclasses.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,11 @@ def _wrap_validator(cls, v, validator, info):
15971597
init_test_cases = [
15981598
({'a': 'hello', 'b': 'bye'}, 'ignore', {'a': 'hello', 'b': 'HELLO'}),
15991599
({'a': 'hello'}, 'ignore', {'a': 'hello', 'b': 'HELLO'}),
1600+
# note, for the case below, we don't actually support this case in Pydantic
1601+
# it's disallowed in Pydantic to have a model with extra='allow' and a field
1602+
# with init=False, so this case isn't really possible at the momment
1603+
# however, no conflict arises here because we don't pass in the value for b
1604+
# to __init__
16001605
({'a': 'hello'}, 'allow', {'a': 'hello', 'b': 'HELLO'}),
16011606
(
16021607
{'a': 'hello', 'b': 'bye'},
@@ -1621,6 +1626,11 @@ def _wrap_validator(cls, v, validator, info):
16211626
'input_value,extra_behavior,expected',
16221627
[
16231628
*init_test_cases,
1629+
# special case - when init=False, extra='allow', and the value is provided
1630+
# currently, it's disallowed in Pydantic to have a model with extra='allow'
1631+
# and a field with init=False, so this case isn't really possible at the momment
1632+
# TODO: open to changing this behavior, and changes won't be significantly breaking
1633+
# because we currently don't support this case
16241634
({'a': 'hello', 'b': 'bye'}, 'allow', {'a': 'hello', 'b': 'HELLO'}),
16251635
],
16261636
)

0 commit comments

Comments
 (0)