diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-03-01 14:20:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 14:20:49 -0800 |
commit | 8af66806c8042501ca32e66efdeb463cf5346cab (patch) | |
tree | 1ed8c48b6187a80b3822cf41431e92972fb0ad20 /test/python/docker | |
parent | 73044b28172fd0df23836052a9061dc41f51f39a (diff) | |
parent | 7927fe01f165bb4a3f381601d847036a3a130182 (diff) | |
download | podman-8af66806c8042501ca32e66efdeb463cf5346cab.tar.gz podman-8af66806c8042501ca32e66efdeb463cf5346cab.tar.bz2 podman-8af66806c8042501ca32e66efdeb463cf5346cab.zip |
Merge pull request #9556 from jwhonce/wip/docker
Refactor python tests to run against python3.9
Diffstat (limited to 'test/python/docker')
-rw-r--r-- | test/python/docker/__init__.py | 14 | ||||
-rw-r--r-- | test/python/docker/compat/README.md (renamed from test/python/docker/README.md) | 12 | ||||
-rw-r--r-- | test/python/docker/compat/__init__.py | 0 | ||||
-rw-r--r-- | test/python/docker/compat/common.py (renamed from test/python/docker/common.py) | 6 | ||||
-rw-r--r-- | test/python/docker/compat/constant.py (renamed from test/python/docker/constant.py) | 0 | ||||
-rw-r--r-- | test/python/docker/compat/test_containers.py (renamed from test/python/docker/test_containers.py) | 11 | ||||
-rw-r--r-- | test/python/docker/compat/test_images.py (renamed from test/python/docker/test_images.py) | 9 | ||||
-rw-r--r-- | test/python/docker/compat/test_system.py (renamed from test/python/docker/test_system.py) | 3 |
8 files changed, 35 insertions, 20 deletions
diff --git a/test/python/docker/__init__.py b/test/python/docker/__init__.py index 351834316..da5630eac 100644 --- a/test/python/docker/__init__.py +++ b/test/python/docker/__init__.py @@ -8,7 +8,7 @@ import tempfile from docker import DockerClient -from test.python.docker import constant +from .compat import constant class Podman(object): @@ -39,7 +39,9 @@ class Podman(object): self.cmd.append("--root=" + os.path.join(self.anchor_directory, "crio")) self.cmd.append("--runroot=" + os.path.join(self.anchor_directory, "crio-run")) - os.environ["REGISTRIES_CONFIG_PATH"] = os.path.join(self.anchor_directory, "registry.conf") + os.environ["REGISTRIES_CONFIG_PATH"] = os.path.join( + self.anchor_directory, "registry.conf" + ) p = configparser.ConfigParser() p.read_dict( { @@ -51,10 +53,14 @@ class Podman(object): with open(os.environ["REGISTRIES_CONFIG_PATH"], "w") as w: p.write(w) - os.environ["CNI_CONFIG_PATH"] = os.path.join(self.anchor_directory, "cni", "net.d") + os.environ["CNI_CONFIG_PATH"] = os.path.join( + self.anchor_directory, "cni", "net.d" + ) os.makedirs(os.environ["CNI_CONFIG_PATH"], exist_ok=True) self.cmd.append("--cni-config-dir=" + os.environ["CNI_CONFIG_PATH"]) - cni_cfg = os.path.join(os.environ["CNI_CONFIG_PATH"], "87-podman-bridge.conflist") + cni_cfg = os.path.join( + os.environ["CNI_CONFIG_PATH"], "87-podman-bridge.conflist" + ) # json decoded and encoded to ensure legal json buf = json.loads( """ diff --git a/test/python/docker/README.md b/test/python/docker/compat/README.md index c10fd636d..50796d66b 100644 --- a/test/python/docker/README.md +++ b/test/python/docker/compat/README.md @@ -13,26 +13,26 @@ To run the tests locally in your sandbox (Fedora 32,33): ### Run the entire test suite +All commands are run from the root of the repository. + ```shell -# python3 -m unittest discover test/python/docker +# python3 -m unittest discover -s test/python/docker ``` Passing the -v option to your test script will instruct unittest.main() to enable a higher level of verbosity, and produce detailed output: ```shell -# python3 -m unittest -v discover test/python/docker +# python3 -m unittest -v discover -s test/python/docker ``` ### Run a specific test class ```shell -# cd test/python/docker -# python3 -m unittest -v tests.test_images +# python3 -m unittest -v test.python.docker.compat.test_images.TestImages ``` ### Run a specific test within the test class ```shell -# cd test/python/docker -# python3 -m unittest tests.test_images.TestImages.test_import_image +# python3 -m unittest test.python.docker.compat.test_images.TestImages.test_tag_valid_image ``` diff --git a/test/python/docker/compat/__init__.py b/test/python/docker/compat/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/test/python/docker/compat/__init__.py diff --git a/test/python/docker/common.py b/test/python/docker/compat/common.py index 11f512495..bdc67c287 100644 --- a/test/python/docker/common.py +++ b/test/python/docker/compat/common.py @@ -1,10 +1,12 @@ from docker import DockerClient -from test.python.docker import constant +from test.python.docker.compat import constant def run_top_container(client: DockerClient): - c = client.containers.create(constant.ALPINE, command="top", detach=True, tty=True, name="top") + c = client.containers.create( + constant.ALPINE, command="top", detach=True, tty=True, name="top" + ) c.start() return c.id diff --git a/test/python/docker/constant.py b/test/python/docker/compat/constant.py index 892293c97..892293c97 100644 --- a/test/python/docker/constant.py +++ b/test/python/docker/compat/constant.py diff --git a/test/python/docker/test_containers.py b/test/python/docker/compat/test_containers.py index 337cacd5c..be70efa67 100644 --- a/test/python/docker/test_containers.py +++ b/test/python/docker/compat/test_containers.py @@ -5,7 +5,8 @@ import unittest from docker import DockerClient, errors -from test.python.docker import Podman, common, constant +from test.python.docker import Podman +from test.python.docker.compat import common, constant class TestContainers(unittest.TestCase): @@ -87,9 +88,11 @@ class TestContainers(unittest.TestCase): self.assertEqual(len(containers), 2) def test_start_container_with_random_port_bind(self): - container = self.client.containers.create(image=constant.ALPINE, - name="containerWithRandomBind", - ports={'1234/tcp': None}) + container = self.client.containers.create( + image=constant.ALPINE, + name="containerWithRandomBind", + ports={"1234/tcp": None}, + ) containers = self.client.containers.list(all=True) self.assertTrue(container in containers) diff --git a/test/python/docker/test_images.py b/test/python/docker/compat/test_images.py index f2b6a5190..842e38f31 100644 --- a/test/python/docker/test_images.py +++ b/test/python/docker/compat/test_images.py @@ -7,7 +7,8 @@ import unittest from docker import DockerClient, errors -from test.python.docker import Podman, common, constant +from test.python.docker import Podman +from test.python.docker.compat import common, constant class TestImages(unittest.TestCase): @@ -78,7 +79,9 @@ class TestImages(unittest.TestCase): self.assertEqual(len(self.client.images.list()), 2) # List images with filter - self.assertEqual(len(self.client.images.list(filters={"reference": "alpine"})), 1) + self.assertEqual( + len(self.client.images.list(filters={"reference": "alpine"})), 1 + ) def test_search_image(self): """Search for image""" @@ -91,7 +94,7 @@ class TestImages(unittest.TestCase): r = self.client.images.search("bogus/bogus") except: return - self.assertTrue(len(r)==0) + self.assertTrue(len(r) == 0) def test_remove_image(self): """Remove image""" diff --git a/test/python/docker/test_system.py b/test/python/docker/compat/test_system.py index 46b90e5f6..131b18991 100644 --- a/test/python/docker/test_system.py +++ b/test/python/docker/compat/test_system.py @@ -5,7 +5,8 @@ import unittest from docker import DockerClient -from test.python.docker import Podman, common, constant +from test.python.docker import Podman, constant +from test.python.docker.compat import common class TestSystem(unittest.TestCase): |