Skip to content

Commit 2cf887a

Browse files
committed
ISSUE-957: chore(tests/containers): fix type annotations for image fixtures
1 parent 06f7f42 commit 2cf887a

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

tests/containers/base_image_test.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ class TestBaseImage:
2929

3030
"""Tests that are applicable for all images we have in this repository."""
3131

32-
def _run_test(self, image: str, test_fn: Callable[[DockerContainer],_]):
32+
def _run_test(self, image: str, test_fn: Callable[[testcontainers.core.container.DockerContainer], None]):
3333
container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0])
3434
container.with_command("/bin/sh -c 'sleep infinity'")
3535
try:
3636
container.start()
3737
test_fn(container)
3838
return
3939
except Exception as e:
40-
pytest.fail(f"Unexpected exception in test: {e}")
40+
pytest.fail(f"Unexpected exception in test: {e}")
4141
finally:
4242
docker_utils.NotebookContainer(container).stop(timeout=0)
4343

4444
# If the return doesn't happen in the try block, fail the test
4545
pytest.fail("The test did not pass as expected.")
46-
46+
4747

4848
def test_elf_files_can_link_runtime_libs(self, subtests: pytest_subtests.SubTests, image):
49-
50-
def test_fn(container: DockerContainer):
49+
50+
def test_fn(container: testcontainers.core.container.DockerContainer):
5151
def check_elf_file():
5252
"""This python function will be executed on the image itself.
5353
That's why it has to have here all imports it needs."""
@@ -123,13 +123,13 @@ def check_elf_file():
123123
continue # it's in ../
124124

125125
with subtests.test(f"{dlib=}"):
126-
pytest.fail(f"{dlib=} has unsatisfied dependencies {deps=}")
126+
pytest.fail(f"{dlib=} has unsatisfied dependencies {deps=}")
127127

128128
self._run_test(image=image, test_fn=test_fn)
129129

130130
def test_oc_command_runs(self, image: str):
131131

132-
def test_fn(container: DockerContainer):
132+
def test_fn(container: testcontainers.core.container.DockerContainer):
133133
ecode, output = container.exec(["/bin/sh", "-c", "oc version"])
134134

135135
logging.debug(output.decode())
@@ -139,19 +139,19 @@ def test_fn(container: DockerContainer):
139139

140140
def test_skopeo_command_runs(self, image: str):
141141

142-
def test_fn(container: DockerContainer):
142+
def test_fn(container: testcontainers.core.container.DockerContainer):
143143
ecode, output = container.exec(["/bin/sh", "-c", "skopeo --version"])
144144

145145
logging.debug(output.decode())
146146
assert ecode == 0
147147

148-
self._run_test(image=image, test_fn=test_fn)
148+
self._run_test(image=image, test_fn=test_fn)
149149

150150
def test_pip_install_cowsay_runs(self, image: str):
151151
"""Checks that the Python virtualenv in the image is writable."""
152152

153153

154-
def test_fn(container: DockerContainer):
154+
def test_fn(container: testcontainers.core.container.DockerContainer):
155155
ecode, output = container.exec(["python3", "-m", "pip", "install", "cowsay"])
156156
logging.debug(output.decode())
157157
assert ecode == 0

tests/containers/conftest.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def workbench_image(image: str):
8080

8181

8282
@pytest.fixture(scope="function")
83-
def jupyterlab_image(image: str):
83+
def jupyterlab_image(image: str) -> docker.models.images.Image:
8484
image_metadata = skip_if_not_workbench_image(image)
8585
if "-jupyter-" not in image_metadata.labels['name']:
8686
pytest.skip(
@@ -90,7 +90,7 @@ def jupyterlab_image(image: str):
9090

9191

9292
@pytest.fixture(scope="function")
93-
def rstudio_image(image: str):
93+
def rstudio_image(image: str) -> docker.models.images.Image:
9494
image_metadata = skip_if_not_workbench_image(image)
9595
if "-rstudio-" not in image_metadata.labels['name']:
9696
pytest.skip(
@@ -100,7 +100,7 @@ def rstudio_image(image: str):
100100

101101

102102
@pytest.fixture(scope="function")
103-
def codeserver_image(image: str):
103+
def codeserver_image(image: str) -> docker.models.images.Image:
104104
image_metadata = skip_if_not_workbench_image(image)
105105
if "-code-server-" not in image_metadata.labels['name']:
106106
pytest.skip(

tests/containers/workbenches/jupyterlab/jupyterlab_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TestJupyterLabImage:
2121

2222
@allure.issue("RHOAIENG-11156")
2323
@allure.description("Check that the HTML for the spinner is contained in the initial page.")
24-
def test_spinner_html_loaded(self, jupyterlab_image: str) -> None:
24+
def test_spinner_html_loaded(self, jupyterlab_image: docker.models.images.Image) -> None:
2525

2626
container = WorkbenchContainer(image=jupyterlab_image, user=4321, group_add=[0])
2727
# if no env is specified, the image will run

0 commit comments

Comments
 (0)