Skip to content

Commit

Permalink
Format codebase with ruff
Browse files Browse the repository at this point in the history
Signed-off-by: Povilas Kanapickas <[email protected]>
  • Loading branch information
p12tic committed Mar 7, 2024
1 parent 63f6301 commit b997d95
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 288 deletions.
412 changes: 157 additions & 255 deletions podman_compose.py

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions pytests/test_can_merge_cmd_ent.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ def test_normalize_service():


def test__parse_compose_file_when_multiple_composes() -> None:
for base_template, override_template, expected_template in copy.deepcopy(
test_cases_merges
):
for base_template, override_template, expected_template in copy.deepcopy(test_cases_merges):
for key in test_keys:
base, override, expected = template_to_expression(
base_template, override_template, expected_template, key
Expand Down
8 changes: 2 additions & 6 deletions pytests/test_normalize_final_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,7 @@ def test__parse_compose_file_when_single_compose() -> None:
# running full parse over merged
#
def test__parse_compose_file_when_multiple_composes() -> None:
for test_input, test_override, expected_result in copy.deepcopy(
test_cases_with_merges
):
for test_input, test_override, expected_result in copy.deepcopy(test_cases_with_merges):
compose_test_1 = {"services": {"test-service": test_input}}
compose_test_2 = {"services": {"test-service": test_override}}
dump_yaml(compose_test_1, "test-compose-1.yaml")
Expand Down Expand Up @@ -273,9 +271,7 @@ def test__parse_compose_file_when_multiple_composes() -> None:
assert compose_expected == actual_compose


def set_args(
podman_compose: PodmanCompose, file_names: list[str], no_normalize: bool
) -> None:
def set_args(podman_compose: PodmanCompose, file_names: list[str], no_normalize: bool) -> None:
podman_compose.global_args = argparse.Namespace()
podman_compose.global_args.file = file_names
podman_compose.global_args.project_name = None
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from setuptools import setup

try:
README = open(
os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8"
).read()
README = open(os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8").read()
except: # noqa: E722 # pylint: disable=bare-except
README = ""

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Defines global pytest fixtures available to all tests.
"""

# pylint: disable=redefined-outer-name
from pathlib import Path
import os
Expand Down
4 changes: 1 addition & 3 deletions tests/test_podman_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def test_podman_compose_extends_w_empty_service():
"python3",
str(main_path.joinpath("podman_compose.py")),
"-f",
str(
main_path.joinpath("tests", "extends_w_empty_service", "docker-compose.yml")
),
str(main_path.joinpath("tests", "extends_w_empty_service", "docker-compose.yml")),
"up",
"-d",
]
Expand Down
5 changes: 2 additions & 3 deletions tests/test_podman_compose_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Tests the podman-compose config command which is used to return defined compose services.
"""

# pylint: disable=redefined-outer-name
import os
from test_podman_compose import capture
Expand Down Expand Up @@ -50,9 +51,7 @@ def test_config_no_profiles(podman_compose_path, profile_compose_file):
),
],
)
def test_config_profiles(
podman_compose_path, profile_compose_file, profiles, expected_services
):
def test_config_profiles(podman_compose_path, profile_compose_file, profiles, expected_services):
"""
Tests podman-compose
:param podman_compose_path: The fixture used to specify the path to the podman compose file.
Expand Down
38 changes: 23 additions & 15 deletions tests/test_podman_compose_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Tests the podman compose up and down commands used to create and remove services.
"""

# pylint: disable=redefined-outer-name
import os
import time
Expand All @@ -17,7 +18,7 @@ def test_exit_from(podman_compose_path, test_path):
podman_compose_path,
"-f",
os.path.join(test_path, "exit-from", "docker-compose.yaml"),
"up"
"up",
]

out, _, return_code = capture(up_cmd + ["--exit-code-from", "sh1"])
Expand All @@ -42,7 +43,7 @@ def test_run(podman_compose_path, test_path):
"sleep",
"/bin/sh",
"-c",
"wget -q -O - http://web:8000/hosts"
"wget -q -O - http://web:8000/hosts",
]

out, _, return_code = capture(run_cmd)
Expand All @@ -61,7 +62,7 @@ def test_run(podman_compose_path, test_path):
"sleep",
"/bin/sh",
"-c",
"wget -q -O - http://web:8000/hosts"
"wget -q -O - http://web:8000/hosts",
]

out, _, return_code = capture(run_cmd)
Expand All @@ -83,8 +84,6 @@ def test_run(podman_compose_path, test_path):


def test_up_with_ports(podman_compose_path, test_path):


up_cmd = [
"coverage",
"run",
Expand All @@ -93,7 +92,7 @@ def test_up_with_ports(podman_compose_path, test_path):
os.path.join(test_path, "ports", "docker-compose.yml"),
"up",
"-d",
"--force-recreate"
"--force-recreate",
]

down_cmd = [
Expand All @@ -103,29 +102,27 @@ def test_up_with_ports(podman_compose_path, test_path):
"-f",
os.path.join(test_path, "ports", "docker-compose.yml"),
"down",
"--volumes"
"--volumes",
]

try:
out, _, return_code = capture(up_cmd)
assert return_code == 0


finally:
out, _, return_code = capture(down_cmd)
assert return_code == 0


def test_down_with_vols(podman_compose_path, test_path):

up_cmd = [
"coverage",
"run",
podman_compose_path,
"-f",
os.path.join(test_path, "vol", "docker-compose.yaml"),
"up",
"-d"
"-d",
]

down_cmd = [
Expand All @@ -135,7 +132,7 @@ def test_down_with_vols(podman_compose_path, test_path):
"-f",
os.path.join(test_path, "vol", "docker-compose.yaml"),
"down",
"--volumes"
"--volumes",
]

try:
Expand All @@ -157,8 +154,20 @@ def test_down_with_vols(podman_compose_path, test_path):


def test_down_with_orphans(podman_compose_path, test_path):

container_id, _ , return_code = capture(["podman", "run", "--rm", "-d", "busybox", "/bin/busybox", "httpd", "-f", "-h", "/etc/", "-p", "8000"])
container_id, _, return_code = capture([
"podman",
"run",
"--rm",
"-d",
"busybox",
"/bin/busybox",
"httpd",
"-f",
"-h",
"/etc/",
"-p",
"8000",
])

down_cmd = [
"coverage",
Expand All @@ -168,7 +177,7 @@ def test_down_with_orphans(podman_compose_path, test_path):
os.path.join(test_path, "ports", "docker-compose.yml"),
"down",
"--volumes",
"--remove-orphans"
"--remove-orphans",
]

out, _, return_code = capture(down_cmd)
Expand All @@ -177,4 +186,3 @@ def test_down_with_orphans(podman_compose_path, test_path):
_, _, exists = capture(["podman", "container", "exists", container_id.decode("utf-8")])

assert exists == 1

1 change: 1 addition & 0 deletions tests/test_podman_compose_up_down.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Tests the podman compose up and down commands used to create and remove services.
"""

# pylint: disable=redefined-outer-name
import os
from test_podman_compose import capture
Expand Down

0 comments on commit b997d95

Please sign in to comment.