@@ -29,25 +29,25 @@ class TestBaseImage:
29
29
30
30
"""Tests that are applicable for all images we have in this repository."""
31
31
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 ]):
33
33
container = testcontainers .core .container .DockerContainer (image = image , user = 23456 , group_add = [0 ])
34
34
container .with_command ("/bin/sh -c 'sleep infinity'" )
35
35
try :
36
36
container .start ()
37
37
test_fn (container )
38
38
return
39
39
except Exception as e :
40
- pytest .fail (f"Unexpected exception in test: { e } " )
40
+ pytest .fail (f"Unexpected exception in test: { e } " )
41
41
finally :
42
42
docker_utils .NotebookContainer (container ).stop (timeout = 0 )
43
43
44
44
# If the return doesn't happen in the try block, fail the test
45
45
pytest .fail ("The test did not pass as expected." )
46
-
46
+
47
47
48
48
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 ):
51
51
def check_elf_file ():
52
52
"""This python function will be executed on the image itself.
53
53
That's why it has to have here all imports it needs."""
@@ -123,13 +123,13 @@ def check_elf_file():
123
123
continue # it's in ../
124
124
125
125
with subtests .test (f"{ dlib = } " ):
126
- pytest .fail (f"{ dlib = } has unsatisfied dependencies { deps = } " )
126
+ pytest .fail (f"{ dlib = } has unsatisfied dependencies { deps = } " )
127
127
128
128
self ._run_test (image = image , test_fn = test_fn )
129
129
130
130
def test_oc_command_runs (self , image : str ):
131
131
132
- def test_fn (container : DockerContainer ):
132
+ def test_fn (container : testcontainers . core . container . DockerContainer ):
133
133
ecode , output = container .exec (["/bin/sh" , "-c" , "oc version" ])
134
134
135
135
logging .debug (output .decode ())
@@ -139,19 +139,19 @@ def test_fn(container: DockerContainer):
139
139
140
140
def test_skopeo_command_runs (self , image : str ):
141
141
142
- def test_fn (container : DockerContainer ):
142
+ def test_fn (container : testcontainers . core . container . DockerContainer ):
143
143
ecode , output = container .exec (["/bin/sh" , "-c" , "skopeo --version" ])
144
144
145
145
logging .debug (output .decode ())
146
146
assert ecode == 0
147
147
148
- self ._run_test (image = image , test_fn = test_fn )
148
+ self ._run_test (image = image , test_fn = test_fn )
149
149
150
150
def test_pip_install_cowsay_runs (self , image : str ):
151
151
"""Checks that the Python virtualenv in the image is writable."""
152
152
153
153
154
- def test_fn (container : DockerContainer ):
154
+ def test_fn (container : testcontainers . core . container . DockerContainer ):
155
155
ecode , output = container .exec (["python3" , "-m" , "pip" , "install" , "cowsay" ])
156
156
logging .debug (output .decode ())
157
157
assert ecode == 0
0 commit comments