diff --git a/changelogs/fragments/ansible-test-layout-detection.yml b/changelogs/fragments/ansible-test-layout-detection.yml new file mode 100644 index 00000000000..946853db943 --- /dev/null +++ b/changelogs/fragments/ansible-test-layout-detection.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-test - Update the logic used to detect when ``ansible-test`` is running from source. diff --git a/test/lib/ansible_test/_internal/ansible_util.py b/test/lib/ansible_test/_internal/ansible_util.py index 9548d37c790..be88ccd8750 100644 --- a/test/lib/ansible_test/_internal/ansible_util.py +++ b/test/lib/ansible_test/_internal/ansible_util.py @@ -231,7 +231,7 @@ def generate_egg_info(path: str) -> None: # minimal PKG-INFO stub following the format defined in PEP 241 # required for older setuptools versions to avoid a traceback when importing pkg_resources from packages like cryptography # newer setuptools versions are happy with an empty directory - # including a stub here means we don't need to locate the existing file or have setup.py generate it when running from source + # including a stub here means we don't need to locate the existing file or run any tools to generate it when running from source pkg_info = ''' Metadata-Version: 1.0 Name: ansible diff --git a/test/lib/ansible_test/_internal/provider/layout/ansible.py b/test/lib/ansible_test/_internal/provider/layout/ansible.py index 3ee818a5b5c..3fad835a39b 100644 --- a/test/lib/ansible_test/_internal/provider/layout/ansible.py +++ b/test/lib/ansible_test/_internal/provider/layout/ansible.py @@ -20,7 +20,7 @@ class AnsibleLayout(LayoutProvider): @staticmethod def is_content_root(path: str) -> bool: """Return True if the given path is a content root for this provider.""" - return os.path.exists(os.path.join(path, 'setup.py')) and os.path.exists(os.path.join(path, 'bin/ansible-test')) + return os.path.isfile(os.path.join(path, 'pyproject.toml')) and os.path.isdir(os.path.join(path, 'test/lib/ansible_test')) def create(self, root: str, paths: list[str]) -> ContentLayout: """Create a Layout using the given root and paths."""