Skip to content

Commit 9d6a3d8

Browse files
committed
test(test_exception): fix to work on Python 3.11
1 parent d5b50e4 commit 9d6a3d8

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

test/test_version.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

44
import logging
5+
import re
56
import textwrap
67

78
import pytest
@@ -47,24 +48,28 @@ async def test_different_version(
4748
) in caplog.record_tuples
4849

4950
@pytest.mark.asyncio
50-
async def test_exception(self, caplog, mocker: MockerFixture):
51+
async def test_exception(
52+
self, caplog: pytest.LogCaptureFixture, mocker: MockerFixture
53+
) -> None:
5154

5255
mocker.patch("requests.get", sideEffect=Exception())
5356

5457
check_latest_version()
5558

56-
assert (
57-
(
58-
"cve_bin_tool",
59-
logging.WARNING,
59+
assert any(
60+
True
61+
for logger_name, logger_level, message in caplog.record_tuples
62+
if logger_name == "cve_bin_tool"
63+
and logger_level == logging.WARNING
64+
and re.match(
6065
textwrap.dedent(
6166
"""
6267
-------------------------- Can't check for the latest version ---------------------------
6368
warning: unable to access 'https://pypi.org/pypi/cve-bin-tool'
64-
Exception details: expected string or bytes-like object
69+
Exception details: expected string or bytes-like object(?:.*)
6570
Please make sure you have a working internet connection or try again later.
6671
"""
6772
),
73+
message,
6874
)
69-
in caplog.record_tuples
7075
)

0 commit comments

Comments
 (0)