Skip to content

Commit 196ed1e

Browse files
Remove dependency to molecule.test (#206)
1 parent c3068ab commit 196ed1e

File tree

15 files changed

+37
-18
lines changed

15 files changed

+37
-18
lines changed

conftest.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import contextlib
22
import os
33
import random
4+
import shutil
45
import string
56

67
import pytest
@@ -84,3 +85,24 @@ def molecule_ephemeral_directory(_fixture_uuid):
8485
return ephemeral_directory(
8586
os.path.join("molecule_test", project_directory, scenario_name),
8687
)
88+
89+
90+
def metadata_lint_update(role_directory: str) -> None:
91+
# By default, ansible-lint will fail on newly-created roles because the
92+
# fields in this file have not been changed from their defaults. This is
93+
# good because molecule should create this file using the defaults, and
94+
# users should receive feedback to change these defaults. However, this
95+
# blocks the testing of 'molecule init' itself, so ansible-lint should
96+
# be configured to ignore these metadata lint errors.
97+
dirname = os.path.dirname(os.path.abspath(__file__))
98+
ansible_lint_src = os.path.join(dirname, ".ansible-lint")
99+
shutil.copy(ansible_lint_src, role_directory)
100+
101+
# Explicitly lint here to catch any unexpected lint errors before
102+
# continuining functional testing. Ansible lint is run at the root
103+
# of the role directory and pointed at the role directory to ensure
104+
# the customize ansible-lint config is used.
105+
with change_dir_to(role_directory):
106+
cmd = ["ansible-lint", "."]
107+
result = run_command(cmd)
108+
assert result.returncode == 0

test/azure/functional/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
# DEALINGS IN THE SOFTWARE.
2121

2222

23-
from molecule.test.conftest import * # noqa
23+
from conftest import * # noqa

test/azure/functional/test_azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
import pytest
2525

26+
from conftest import change_dir_to
2627
from molecule import logger
27-
from molecule.test.conftest import change_dir_to
2828
from molecule.util import run_command
2929

3030
LOG = logger.get_logger(__name__)

test/containers/functional/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
# DEALINGS IN THE SOFTWARE.
2121
"""PyTest Config."""
2222

23-
from molecule.test.conftest import * # noqa pylint: disable=wildcard-import,unused-wildcard-import
23+
from conftest import * # noqa pylint: disable=wildcard-import,unused-wildcard-import

test/containers/functional/test_containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"""Functional Tests."""
2222
import os
2323

24+
from conftest import change_dir_to, molecule_directory
2425
from molecule import logger
25-
from molecule.test.conftest import change_dir_to, molecule_directory
2626
from molecule.util import run_command
2727

2828
LOG = logger.get_logger(__name__)

test/docker/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Pytest Fixtures."""
2-
import pytest
2+
from conftest import random_string, temp_dir # noqa
33

4-
from molecule.test.conftest import random_string, temp_dir # noqa
4+
import pytest
55

66

77
@pytest.fixture()

test/docker/test_func.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
import pytest
88

9+
from conftest import change_dir_to
910
from molecule import logger
10-
from molecule.test.conftest import change_dir_to
1111
from molecule.util import run_command
1212

1313
LOG = logger.get_logger(__name__)

test/ec2/functional/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
# DEALINGS IN THE SOFTWARE.
2121

2222

23-
from molecule.test.conftest import * # noqa
23+
from conftest import * # noqa

test/ec2/functional/test_ec2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323

2424
import pytest
2525

26+
from conftest import change_dir_to, metadata_lint_update
2627
from molecule import logger
27-
from molecule.test.b_functional.conftest import metadata_lint_update
28-
from molecule.test.conftest import change_dir_to
2928
from molecule.util import run_command
3029

3130
LOG = logger.get_logger(__name__)

test/gce/functional/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
# DEALINGS IN THE SOFTWARE.
2121

2222

23-
from molecule.test.conftest import * # noqa
23+
from conftest import * # noqa

0 commit comments

Comments
 (0)