From 0ff04ad41b55e19af8671b8ea33030b10927771a Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Thu, 7 Jun 2018 09:18:07 -0500 Subject: [PATCH] Fix wrong python keyword (followup to #36357) (#41067) Also add tests around that code path --- lib/ansible/parsing/dataloader.py | 2 +- test/units/playbook/role/test_role.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/ansible/parsing/dataloader.py b/lib/ansible/parsing/dataloader.py index e520c58302..0b9a3ff9f2 100644 --- a/lib/ansible/parsing/dataloader.py +++ b/lib/ansible/parsing/dataloader.py @@ -422,7 +422,7 @@ class DataLoader: if allow_dir: found.extend(self._get_dir_vars_files(to_text(full_path), extensions)) else: - next + continue else: found.append(full_path) break diff --git a/test/units/playbook/role/test_role.py b/test/units/playbook/role/test_role.py index b3fb063cb0..3730b43d56 100644 --- a/test/units/playbook/role/test_role.py +++ b/test/units/playbook/role/test_role.py @@ -147,6 +147,26 @@ class TestRole(unittest.TestCase): 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):