Skip to content

Commit 630fb43

Browse files
committed
mypy
1 parent b95a991 commit 630fb43

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/tests/conftest.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
from pathlib import Path
1212
import xml.etree.ElementTree as ET
13-
from typing import Callable, Optional, Union, Dict, Any, List
13+
from typing import Callable, Optional, Union, Dict, Any, List, Tuple, Generator
1414
from opengeodeweb_viewer import config
1515
from opengeodeweb_microservice.database.connection import get_session, init_database
1616
from opengeodeweb_microservice.database.data import Data
@@ -31,7 +31,9 @@ def __init__(self, log: str) -> None:
3131
self._init_ws()
3232
self._drain_initial_messages()
3333

34-
def call(self, rpc: str, params: List[Dict[str, Any]] = [{}]) -> None:
34+
def call(self, rpc: str, params: List[Dict[str, Any]] = None) -> None:
35+
if params is None:
36+
params = [{}]
3537
return self.ws.send(
3638
json.dumps(
3739
{
@@ -57,9 +59,10 @@ def get_response(self) -> Union[bytes, Dict[str, Any], str]:
5759
if isinstance(response, bytes):
5860
return response
5961
try:
60-
return json.loads(response)
62+
parsed = json.loads(response)
63+
return parsed
6164
except Exception:
62-
return response
65+
return str(response)
6366

6467
@staticmethod
6568
def _reader_for_file(path: str) -> vtk.vtkImageReader2:
@@ -147,7 +150,7 @@ class FixtureHelper:
147150
def __init__(self, root_path: Path) -> None:
148151
self.root_path = Path(root_path)
149152

150-
def get_xprocess_args(self) -> tuple:
153+
def get_xprocess_args(self) -> Tuple[str, type, type]:
151154
class Starter(ProcessStarter):
152155
terminate_on_interrupt = True
153156
pattern = "wslink: Starting factory"
@@ -166,7 +169,7 @@ class Starter(ProcessStarter):
166169

167170

168171
@pytest.fixture
169-
def server(xprocess) -> ServerMonitor:
172+
def server(xprocess: Any) -> Generator[ServerMonitor, None, None]:
170173
name, Starter, Monitor = HELPER.get_xprocess_args()
171174
os.environ["PYTHON_ENV"] = "test"
172175
_, log = xprocess.ensure(name, Starter)

src/tests/test_viewer_protocols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_take_screenshot(
115115
server.get_response()
116116
server.get_response()
117117
blob = server.get_response()
118-
print(f"{blob=}", flush=True)
118+
print(f"{blob!r}", flush=True)
119119
assert type(blob) is bytes
120120

121121
with open(os.path.join(server.test_output_dir, "test.png"), "wb") as f:
@@ -144,7 +144,7 @@ def test_take_screenshot(
144144
server.get_response()
145145
server.get_response()
146146
blob = server.get_response()
147-
print(f"{blob=}", flush=True)
147+
print(f"{blob!r}", flush=True)
148148
assert type(blob) is bytes
149149

150150
with open(os.path.join(server.test_output_dir, "test.png"), "wb") as f:

0 commit comments

Comments
 (0)