mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 14:21:26 -07:00
Split up the base_parser function
The goal of breaking apart the base_parser() function is to get rid of a bunch of conditionals and parameters in the code and, instead, make code look like simple composition. When splitting, a choice had to be made as to whether this would operate by side effect (modifying a passed in parser) or side effect-free (returning a new parser everytime). Making a version that's side-effect-free appears to be fighting with the optparse API (it wants to work by creating a parser object, configuring the object, and then parsing the arguments with it) so instead, make it clear that our helper functions are modifying the passed in parser by (1) not returning the parser and (2) changing the function names to be more clear that it is operating by side-effect. Also move all of the generic optparse code, along with the argument context classes, into a new subdirectory.
This commit is contained in:
parent
afdbb0d9d5
commit
7e92ff823e
21 changed files with 545 additions and 486 deletions
|
@ -21,8 +21,8 @@ from __future__ import (absolute_import, division, print_function)
|
|||
from units.compat import unittest
|
||||
from units.compat.mock import MagicMock
|
||||
|
||||
from ansible import arguments
|
||||
from ansible import context
|
||||
from ansible.arguments import context_objects as co
|
||||
from ansible.executor.task_queue_manager import TaskQueueManager
|
||||
from ansible.playbook import Playbook
|
||||
from ansible.plugins.callback import CallbackBase
|
||||
|
@ -38,7 +38,7 @@ class TestTaskQueueManagerCallbacks(unittest.TestCase):
|
|||
passwords = []
|
||||
|
||||
# Reset the stored command line args
|
||||
arguments.GlobalCLIArgs._Singleton__instance = None
|
||||
co.GlobalCLIArgs._Singleton__instance = None
|
||||
self._tqm = TaskQueueManager(inventory, variable_manager, loader, passwords)
|
||||
self._playbook = Playbook(loader)
|
||||
|
||||
|
@ -51,7 +51,7 @@ class TestTaskQueueManagerCallbacks(unittest.TestCase):
|
|||
|
||||
def tearDown(self):
|
||||
# Reset the stored command line args
|
||||
arguments.GlobalCLIArgs._Singleton__instance = None
|
||||
co.GlobalCLIArgs._Singleton__instance = None
|
||||
|
||||
def test_task_queue_manager_callbacks_v2_playbook_on_start(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue