Skip to content

Commit

Permalink
tests: Fix Path exception matching for Python 3.12
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dbnicholson committed Jan 11, 2024
1 parent 2aa357f commit 6869703
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/test_receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,11 +1026,9 @@ def test_load_unknown(self, tmp_path, caplog):
assert expected_log_record in caplog.record_tuples

def test_load_invalid(self, tmp_path):
with pytest.raises(receive.OTReceiveConfigError) as excinfo:
# Passing a non-path as the config file should fail.
with pytest.raises(receive.OTReceiveConfigError, match='PathLike'):
receive.OTReceiveConfig.load([True])
assert str(excinfo.value) == (
'expected str, bytes or os.PathLike object, not bool'
)

path = tmp_path / 'ostree-receive.conf'
data = {
Expand Down

0 comments on commit 6869703

Please sign in to comment.