Skip to content

Commit

Permalink
Ensure unit test paths for connection and inventory plugins are based…
Browse files Browse the repository at this point in the history
… on the context (#73877)
  • Loading branch information
tremble authored and mattclay committed Mar 19, 2021
1 parent 21eac8a commit 84e61b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions 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).
8 changes: 5 additions & 3 deletions test/lib/ansible_test/_internal/classification.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 84e61b3

Please sign in to comment.