Skip to content
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

Tests fail with Python 3.12 #16

Closed
andrewshadura opened this issue Jan 11, 2024 · 1 comment · Fixed by #17
Closed

Tests fail with Python 3.12 #16

andrewshadura opened this issue Jan 11, 2024 · 1 comment · Fixed by #17

Comments

@andrewshadura
Copy link

andrewshadura commented Jan 11, 2024

One of the tests verifies the exact text of an exception matches a string literal; however, 3.12 changed that text, so it no longer matches.

=================================== FAILURES ===================================
_________________________ TestConfig.test_load_invalid _________________________

self = <tests.test_receive.TestConfig object at 0x7f307b6562d0>
tmp_path = PosixPath('/tmp/pytest-of-user42/pytest-19/test_load_invalid0')

    def test_load_invalid(self, tmp_path):
        with pytest.raises(receive.OTReceiveConfigError) as excinfo:
            receive.OTReceiveConfig.load([True])
>       assert str(excinfo.value) == (
            'expected str, bytes or os.PathLike object, not bool'
        )
E       assert "argument sho...r, not 'bool'" == 'expected str...ect, not bool'
E         - expected str, bytes or os.PathLike object, not bool
E         + argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'bool'

tests/test_receive.py:818: AssertionError

It would be great if the could be fixed in a manner preserving compatibility with the earlier Python versions as well.

@dbnicholson
Copy link
Owner

Ah, that was silly to match the whole exception string. I think this can be changed to a simple match on PathLike since that's all it's trying to determine and I feel like that's less likely to change.

dbnicholson added a commit that referenced this issue Jan 11, 2024
On Python 3.12 the `pathlib.Path()` exception string has changed to
`argument should be a str or an os.PathLike object where __fspath__
returns a str, not 'bool'`. Matching the whole exception string was
never a great idea, but it seems like `PathLike` will always be in it
somewhere.

Fixes: #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants