From 84e61b32f83b5099d0cd923914d17474540cbb03 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Fri, 12 Mar 2021 21:46:40 +0100 Subject: [PATCH] Ensure unit test paths for connection and inventory plugins are based on the context (#73877) --- changelogs/fragments/73876-ansible_test-units.yml | 2 ++ test/lib/ansible_test/_internal/classification.py | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/73876-ansible_test-units.yml diff --git a/changelogs/fragments/73876-ansible_test-units.yml b/changelogs/fragments/73876-ansible_test-units.yml new file mode 100644 index 00000000000000..31611fc3816b82 --- /dev/null +++ b/changelogs/fragments/73876-ansible_test-units.yml @@ -0,0 +1,2 @@ +bugfixes: +- ansible-test - ensure unit test paths for connection and inventory plugins are correctly identified for collections (https://github.com/ansible/ansible/issues/73876). diff --git a/test/lib/ansible_test/_internal/classification.py b/test/lib/ansible_test/_internal/classification.py index e8b5a18544ce4b..614c002d02e5f0 100644 --- a/test/lib/ansible_test/_internal/classification.py +++ b/test/lib/ansible_test/_internal/classification.py @@ -521,15 +521,16 @@ def _classify_common(self, path): # type: (str) -> t.Optional[t.Dict[str, str]] } if is_subdir(path, data_context().content.plugin_paths['connection']): + units_dir = os.path.join(data_context().content.unit_path, 'plugins', 'connection') if name == '__init__': return { 'integration': self.integration_all_target, 'windows-integration': self.integration_all_target, 'network-integration': self.integration_all_target, - 'units': 'test/units/plugins/connection/', + 'units': units_dir, } - units_path = 'test/units/plugins/connection/test_%s.py' % name + units_path = os.path.join(units_dir, 'test_%s.py' % name) if units_path not in self.units_paths: units_path = None @@ -605,7 +606,8 @@ def _classify_common(self, path): # type: (str) -> t.Optional[t.Dict[str, str]] posix_integration_fallback = None target = self.integration_targets_by_name.get('inventory_%s' % name) - units_path = 'test/units/plugins/inventory/test_%s.py' % name + units_dir = os.path.join(data_context().content.unit_path, 'plugins', 'inventory') + units_path = os.path.join(units_dir, 'test_%s.py' % name) if units_path not in self.units_paths: units_path = None