konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.72k stars 106 forks source link

Test failure with Python 3.10 #167

Closed fabaff closed 1 year ago

fabaff commented 2 years ago

There is a test failure with Python 3.10

============================= test session starts ==============================
platform linux -- Python 3.10.1, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /build/source
collected 168 items                                                            

tests/test_dataclasses.py ......                                         [  3%]
tests/test_types.py .................................................... [ 34%]
...............................                                          [ 52%]
tests/core/test_base.py .............                                    [ 60%]
tests/core/test_collection.py .................                          [ 70%]
tests/core/test_config.py ...............                                [ 79%]
tests/core/test_init_var.py ..                                           [ 80%]
tests/core/test_literal.py ....                                          [ 83%]
tests/core/test_optional.py ..............                               [ 91%]
tests/core/test_type.py .                                                [ 92%]
tests/core/test_union.py ..F..........                                   [100%]

=================================== FAILURES ===================================
___________________ test_from_dict_with_union_and_wrong_data ___________________

    def test_from_dict_with_union_and_wrong_data():
        @dataclass
        class X:
            i: Union[int, str]

        with pytest.raises(UnionMatchError) as exception_info:
            from_dict(X, {"i": 1.0})

>       assert str(exception_info.value) == 'can not match type "float" to any type of "i" union: typing.Union[int, str]'
E       assert 'can not matc... union: Union' == 'can not matc...ion[int, str]'
E         Skipping 43 identical leading characters in diff, use -v to show
E         - i" union: typing.Union[int, str]
E         + i" union: Union

tests/core/test_union.py:45: AssertionError
=========================== short test summary info ============================
FAILED tests/core/test_union.py::test_from_dict_with_union_and_wrong_data - a...
======================== 1 failed, 167 passed in 0.40s =========================
MaciejHanszke commented 2 years ago

PR @ https://github.com/konradhalas/dacite/pull/169

konradhalas commented 1 year ago

@fabaff thank you for reporting this issue - it's fixed already via https://github.com/konradhalas/dacite/pull/169