Skip to content

Commit

Permalink
more pylint cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Bas Zoetekouw <[email protected]>
  • Loading branch information
baszoetekouw committed Mar 7, 2024
1 parent 4e64c7f commit 7898e34
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 30 deletions.
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# pylint: disable=redefined-outer-name
from pathlib import Path
import os

import pytest


Expand Down
13 changes: 2 additions & 11 deletions tests/test_podman_compose.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
from pathlib import Path
import subprocess


def capture(command):
proc = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
out, err = proc.communicate()
return out, err, proc.returncode
from utils import capture


def test_podman_compose_extends_w_file_subdir():
Expand Down Expand Up @@ -52,7 +43,7 @@ def test_podman_compose_extends_w_file_subdir():
out, _, returncode = capture(command_up)
assert 0 == returncode
# check container was created and exists
out, err, returncode = capture(command_check_container)
out, _, returncode = capture(command_check_container)
assert 0 == returncode
assert b'localhost/subdir_test:me\n' == out
out, _, returncode = capture(command_down)
Expand Down
11 changes: 1 addition & 10 deletions tests/test_podman_compose_include.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
from pathlib import Path
import subprocess


def capture(command):
proc = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
out, err = proc.communicate()
return out, err, proc.returncode
from utils import capture


def test_podman_compose_include():
Expand Down
18 changes: 9 additions & 9 deletions tests/test_podman_compose_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def test_exit_from(podman_compose_path, test_path):
"up"
]

out, _, return_code = capture(up_cmd + ["--exit-code-from", "sh1"])
_, _, return_code = capture(up_cmd + ["--exit-code-from", "sh1"])
assert return_code == 1

out, _, return_code = capture(up_cmd + ["--exit-code-from", "sh2"])
_, _, return_code = capture(up_cmd + ["--exit-code-from", "sh2"])
assert return_code == 2


Expand Down Expand Up @@ -105,11 +105,11 @@ def test_up_with_ports(podman_compose_path, test_path):
]

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

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


Expand All @@ -136,18 +136,18 @@ def test_down_with_vols(podman_compose_path, test_path):
]

try:
out, _, return_code = capture(["podman", "volume", "create", "my-app-data"])
_, _, return_code = capture(["podman", "volume", "create", "my-app-data"])
assert return_code == 0
out, _, return_code = capture(["podman", "volume", "create", "actual-name-of-volume"])
_, _, return_code = capture(["podman", "volume", "create", "actual-name-of-volume"])
assert return_code == 0

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

capture(["podman", "inspect", "volume", ""])

finally:
out, _, return_code = capture(down_cmd)
_, _, return_code = capture(down_cmd)
capture(["podman", "volume", "rm", "my-app-data"])
capture(["podman", "volume", "rm", "actual-name-of-volume"])
assert return_code == 0
Expand All @@ -170,7 +170,7 @@ def test_down_with_orphans(podman_compose_path, test_path):
"--remove-orphans"
]

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

_, _, exists = capture(["podman", "container", "exists", container_id.decode("utf-8")])
Expand Down
11 changes: 11 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import subprocess


def capture(command):
proc = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
out, err = proc.communicate()
return out, err, proc.returncode

0 comments on commit 7898e34

Please sign in to comment.