Skip to content

Commit

Permalink
Fix wrong python keyword (followup to ansible#36357) (ansible#41067)
Browse files Browse the repository at this point in the history
Also add tests around that code path
  • Loading branch information
agaffney authored and kbreit committed Jul 3, 2018
1 parent eff4034 commit 3108335
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ansible/parsing/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def find_vars_files(self, path, name, extensions=None, allow_dir=True):
if allow_dir:
found.extend(self._get_dir_vars_files(to_text(full_path), extensions))
else:
next
continue
else:
found.append(full_path)
break
Expand Down
20 changes: 20 additions & 0 deletions test/units/playbook/role/test_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ def test_load_role_with_tasks(self):
self.assertEqual(len(r._task_blocks), 1)
assert isinstance(r._task_blocks[0], Block)

@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
def test_load_role_with_tasks_dir_vs_file(self):

fake_loader = DictDataLoader({
"/etc/ansible/roles/foo_tasks/tasks/custom_main/foo.yml": """
- command: bar
""",
"/etc/ansible/roles/foo_tasks/tasks/custom_main.yml": """
- command: baz
""",
})

mock_play = MagicMock()
mock_play.ROLE_CACHE = {}

i = RoleInclude.load('foo_tasks', play=mock_play, loader=fake_loader)
r = Role.load(i, play=mock_play, from_files=dict(tasks='custom_main'))

self.assertEqual(r._task_blocks[0]._ds[0]['command'], 'baz')

@patch('ansible.playbook.role.definition.unfrackpath', mock_unfrackpath_noop)
def test_load_role_with_handlers(self):

Expand Down

0 comments on commit 3108335

Please # to comment.