mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-22 18:31:25 -07:00
[PR #7181/d6ebba1a backport][stable-7] cmd tests improvement (#7187)
cmd tests improvement (#7181)
* cmd tests improvement
* fix sanity
* remove commented line
* fixed class init code
(cherry picked from commit d6ebba1aea
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
80113063ac
commit
7c04aaa48f
4 changed files with 11 additions and 8 deletions
|
@ -6,7 +6,6 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
from collections import namedtuple
|
||||
from itertools import chain, repeat
|
||||
|
||||
|
@ -19,16 +18,20 @@ RunCmdCall = namedtuple("RunCmdCall", ["command", "environ", "rc", "out", "err"]
|
|||
|
||||
|
||||
class CmdRunnerTestHelper(object):
|
||||
def __init__(self, command, test_cases):
|
||||
self.command = command
|
||||
def __init__(self, test_cases):
|
||||
self._test_cases = test_cases
|
||||
self.testcases = self._make_test_cases()
|
||||
if isinstance(test_cases, (list, tuple)):
|
||||
self.testcases = test_cases
|
||||
else:
|
||||
self.testcases = self._make_test_cases()
|
||||
|
||||
@property
|
||||
def cmd_fixture(self):
|
||||
@pytest.fixture
|
||||
def patch_bin(mocker):
|
||||
mocker.patch('ansible.module_utils.basic.AnsibleModule.get_bin_path', return_value=os.path.join('/testbin', self.command))
|
||||
def mockie(self, path, *args, **kwargs):
|
||||
return "/testbin/{0}".format(path)
|
||||
mocker.patch('ansible.module_utils.basic.AnsibleModule.get_bin_path', mockie)
|
||||
|
||||
return patch_bin
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue