Skip to content

Commit

Permalink
from pathlib import Path
Browse files Browse the repository at this point in the history
  • Loading branch information
hswong3i committed Jan 22, 2025
1 parent 7ce13d2 commit 2e75b68
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 13 deletions.
2 changes: 2 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import pytest

from pathlib import Path

from molecule import config, logger, util
from molecule.scenario import ephemeral_directory
from molecule.app import get_app
Expand Down
1 change: 1 addition & 0 deletions src/molecule_plugins/podman/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import os
import warnings
from shutil import which
from pathlib import Path

from ansible_compat.runtime import Runtime
from packaging.version import Version
Expand Down
2 changes: 2 additions & 0 deletions test/azure/functional/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import pytest

from pathlib import Path

from conftest import change_dir_to
from molecule import logger
from molecule.app import get_app
Expand Down
2 changes: 2 additions & 0 deletions test/containers/functional/test_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"""Functional Tests."""
import os

from pathlib import Path

from conftest import change_dir_to, molecule_directory
from molecule import logger
from molecule.app import get_app
Expand Down
14 changes: 7 additions & 7 deletions test/docker/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ def test_command_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) ->
"--driver-name",
DRIVER,
]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0

assert scenario_directory.exists()

# run molecule reset as this may clean some leftovers from other
# test runs and also ensure that reset works.
result = get_app(Path()).run_command(["molecule", "reset"]) # default scenario
result = get_app(tmp_path).run_command(["molecule", "reset"]) # default scenario
assert result.returncode == 0

result = get_app(Path()).run_command(["molecule", "reset", "-s", scenario_name])
result = get_app(tmp_path).run_command(["molecule", "reset", "-s", scenario_name])
assert result.returncode == 0

cmd = ["molecule", "--debug", "test", "-s", scenario_name]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0


Expand All @@ -63,7 +63,7 @@ def test_command_static_scenario() -> None:
"""Validate that the scenario we included with code still works."""
cmd = ["molecule", "test"]

result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0


Expand All @@ -72,7 +72,7 @@ def test_dockerfile_with_context() -> None:
"""Verify that Dockerfile.j2 with context works."""
with change_dir_to("test/docker/scenarios/with-context"):
cmd = ["molecule", "--debug", "test"]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0


Expand All @@ -82,5 +82,5 @@ def test_env_substitution() -> None:
os.environ["MOLECULE_ROLE_IMAGE"] = "debian:bullseye"
with change_dir_to("test/docker/scenarios/env-substitution"):
cmd = ["molecule", "--debug", "test"]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0
2 changes: 2 additions & 0 deletions test/ec2/functional/test_ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import pytest

from pathlib import Path

from conftest import change_dir_to, metadata_lint_update
from molecule import logger
from molecule.app import get_app
Expand Down
2 changes: 2 additions & 0 deletions test/gce/functional/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import pytest

from pathlib import Path

from conftest import change_dir_to, metadata_lint_update
from molecule import logger
from molecule.app import get_app
Expand Down
6 changes: 4 additions & 2 deletions test/openstack/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import shutil
import subprocess

from pathlib import Path

import pytest

import openstack
Expand Down Expand Up @@ -53,7 +55,7 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) -
"--driver-name",
DRIVER,
]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0

assert scenario_directory.exists()
Expand All @@ -71,7 +73,7 @@ def test_openstack_init_and_test_scenario(tmp_path: pathlib.Path, DRIVER: str) -
shutil.copyfile(testconf, confpath)

cmd = ["molecule", "--debug", "test", "-s", scenario_name]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0


Expand Down
10 changes: 6 additions & 4 deletions test/podman/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pathlib
import subprocess

from pathlib import Path

from conftest import change_dir_to
from molecule import logger
from molecule.app import get_app
Expand Down Expand Up @@ -35,21 +37,21 @@ def test_podman_command_init_scenario(tmp_path: pathlib.Path):
"--driver-name",
"podman",
]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0

assert scenario_directory.exists()

# run molecule reset as this may clean some leftovers from other
# test runs and also ensure that reset works.
result = get_app(Path()).run_command(["molecule", "reset"]) # default sceanario
result = get_app(tmp_path).run_command(["molecule", "reset"]) # default sceanario
assert result.returncode == 0

result = get_app(Path()).run_command(["molecule", "reset", "-s", scenario_name])
result = get_app(tmp_path).run_command(["molecule", "reset", "-s", scenario_name])
assert result.returncode == 0

cmd = ["molecule", "--debug", "test", "-s", scenario_name]
result = get_app(Path()).run_command(cmd)
result = get_app(tmp_path).run_command(cmd)
assert result.returncode == 0


Expand Down
2 changes: 2 additions & 0 deletions test/vagrant-plugin/functional/test_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import pytest
import vagrant

from pathlib import Path

from conftest import change_dir_to
from molecule import logger, util
from molecule.scenario import ephemeral_directory
Expand Down

0 comments on commit 2e75b68

Please sign in to comment.