Skip to content

Commit 2a75e5a

Browse files
committed
Make type hints for mock HTTP responses work in older Python
1 parent 7a1b141 commit 2a75e5a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/http/core/test_connector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
import unittest
66
from http import HTTPStatus
7-
from typing import Any, Optional
7+
from typing import Any, Optional, Union
88
from unittest.mock import MagicMock, Mock, patch
99

1010
import requests as requests_lib
@@ -36,7 +36,7 @@
3636

3737

3838
def new_mock_empty_response(
39-
status: Optional[int | HTTPStatus] = None,
39+
status: Optional[Union[int, HTTPStatus]] = None,
4040
) -> requests_lib.Response:
4141
# pylint: disable=protected-access
4242
response = requests_lib.Response()
@@ -50,7 +50,7 @@ def new_mock_empty_response(
5050

5151
def new_mock_json_response(
5252
content: Optional[Any] = None,
53-
status: Optional[int | HTTPStatus] = None,
53+
status: Optional[Union[int, HTTPStatus]] = None,
5454
) -> requests_lib.Response:
5555
# pylint: disable=protected-access
5656
response = requests_lib.Response()

tests/http/openvasd/test_openvasd1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import unittest
66
from http import HTTPStatus
7-
from typing import Optional
7+
from typing import Optional, Union
88
from unittest.mock import Mock, patch
99

1010
from gvm.errors import InvalidArgumentType
@@ -14,7 +14,7 @@
1414

1515

1616
def new_mock_empty_response(
17-
status: Optional[int | HTTPStatus] = None,
17+
status: Optional[Union[int, HTTPStatus]] = None,
1818
headers: Optional[dict[str, str]] = None,
1919
):
2020
if status is None:

0 commit comments

Comments
 (0)