New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix master #1682
Fix master #1682
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1682 +/- ##
==========================================
+ Coverage 99.68% 99.94% +0.25%
==========================================
Files 21 21
Lines 3863 3863
Branches 767 767
==========================================
+ Hits 3851 3861 +10
+ Misses 10 1 -9
+ Partials 2 1 -1
Continue to review full report at Codecov.
|
|
The strange part is that tests were passing on windows somehow. This potentially means that pydantic could behave differently on this platform |
@samuelcolvin Do you want some help to investigate this matter? |
This is preventing v1.6 from being released. Any help on what's going wrong would be useful, I'll try and look later today. |
I see this as a plan of investigating and fixing the issue:
|
So the real problem is that we have a "regression" with #1545 where def test_conlist():
class Model(BaseModel):
v: conlist(int) = 'a'
m = Model()
assert m.v == 'a' used to be valid with |
Meh I just tried on a windows 10 and python 3.8.2: tests\test_types.py:249 (test_constrained_set_default)
def test_constrained_set_default():
class ConSetModelMax(BaseModel):
v: conset(int) = {}
> m = ConSetModelMax() Would be nice to be able to connect via SSH on the windows 2019 server machine of github |
Well, I looked at CI output closer and noticed that tests actually failed, but CI did not detect it for some reason: ================================== FAILURES ===================================
________________________ test_env_file_custom_encoding ________________________
tmp_path = WindowsPath('C:/Users/runneradmin/AppData/Local/Temp/pytest-of-runneradmin/pytest-0/test_env_file_custom_encoding0')
@pytest.mark.skipif(not dotenv, reason='python-dotenv not installed')
def test_env_file_custom_encoding(tmp_path):
p = tmp_path / '.env'
p.write_text('pika=p!�@', encoding='latin-1')
class Settings(BaseSettings):
pika: str
with pytest.raises(UnicodeDecodeError):
> Settings(_env_file=str(p))
E Failed: DID NOT RAISE <class 'UnicodeDecodeError'>
tests\test_settings.py:557: Failed
________________________ test_constrained_set_default _________________________
def test_constrained_set_default():
class ConSetModelMax(BaseModel):
v: conset(int) = {}
> m = ConSetModelMax()
tests\test_types.py:254:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
__pydantic_self__ = ConSetModelMax(), data = {}, values = {}, fields_set = set()
validation_error = ValidationError(model='ConSetModelMax', errors=[{'loc': ('v',), 'msg': 'value is not a valid set', 'type': 'type_error.set'}])
def __init__(__pydantic_self__, **data: Any) -> None:
"""
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
"""
# Uses something other than `self` the first arg to allow "self" as a settable attribute
if TYPE_CHECKING:
__pydantic_self__.__dict__: Dict[str, Any] = {}
__pydantic_self__.__fields_set__: 'SetStr' = set()
values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
if validation_error:
> raise validation_error
E pydantic.error_wrappers.ValidationError: 1 validation error for ConSetModelMax
E v
E value is not a valid set (type=type_error.set)
pydantic\main.py:346: ValidationError
=========================== short test summary info ===========================
FAILED tests/test_settings.py::test_env_file_custom_encoding - Failed: DID NO...
FAILED tests/test_types.py::test_constrained_set_default - pydantic.error_wra...
================= 2 failed, 1707 passed, 9 skipped in 27.38s ==================
mingw32-make: *** [Makefile:42: test] Error 1 |
Thanks for checking @MrMrRobat. It's reassuring! I was afraid it was ok only on some windows systems. |
this is really weird, I've done quite a lot of digging but can't find anyone else having this problem with steps passing when I think it must be some weird way gnu make and powershell are not working correctly together, but I can't find any clues about what's wrong. |
@samuelcolvin Don't you think we could ask someone from github (actions) to have a look ? Nothing has changed on pydantic side regarding the CI. The exit code is 1 and fails on local. And we are talking about |
@samuelcolvin @PrettyWood Some examples from another project I work on. |
Thanks for sharing @Kilo59 (and kudos to you for this project!). But I don't think the issue is to know if |
* test: add regression test with wrong type default * fix: remove always on conlist and conset * fix: use utf8 as default encoding on all OS
@MrMrRobat @PrettyWood thank you both for your help. I'm working on the windows problem now on #1700 |
Trying to fix master.