Fix pylint disallowed-name errors (#80854)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/80868/head
Abhijeet Kasurde 1 year ago committed by GitHub
parent a551e8db80
commit 652ddc4078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -238,7 +238,7 @@ class PlaybookExecutor:
else:
basedir = '~/'
(retry_name, _) = os.path.splitext(os.path.basename(playbook_path))
(retry_name, ext) = os.path.splitext(os.path.basename(playbook_path))
filename = os.path.join(basedir, "%s.retry" % retry_name)
if self._generate_retry_inventory(filename, retries):
display.display("\tto retry, use: --limit @%s\n" % filename)

@ -231,7 +231,7 @@ class TaskQueueManager:
callback_name = cnames[0]
else:
# fallback to 'old loader name'
(callback_name, _) = os.path.splitext(os.path.basename(callback_plugin._original_path))
(callback_name, ext) = os.path.splitext(os.path.basename(callback_plugin._original_path))
display.vvvvv("Attempting to use '%s' callback." % (callback_name))
if callback_type == 'stdout':

@ -81,7 +81,7 @@ def _fileobj_to_fd(fileobj):
# Python 3.5 uses a more direct route to wrap system calls to increase speed.
if sys.version_info >= (3, 5):
def _syscall_wrapper(func, _, *args, **kwargs):
def _syscall_wrapper(func, dummy, *args, **kwargs):
""" This is the short-circuit version of the below logic
because in Python 3.5+ all selectors restart system calls. """
try:
@ -342,8 +342,8 @@ if hasattr(select, "select"):
timeout = None if timeout is None else max(timeout, 0.0)
ready = []
r, w, _ = _syscall_wrapper(self._select, True, self._readers,
self._writers, timeout=timeout)
r, w, dummy = _syscall_wrapper(self._select, True, self._readers,
self._writers, timeout=timeout)
r = set(r)
w = set(w)
for fd in r | w:
@ -649,7 +649,7 @@ elif 'PollSelector' in globals(): # Platform-specific: Linux
elif 'SelectSelector' in globals(): # Platform-specific: Windows
DefaultSelector = SelectSelector
else: # Platform-specific: AppEngine
def no_selector(_):
def no_selector(dummy):
raise ValueError("Platform does not have a selector")
DefaultSelector = no_selector
HAS_SELECT = False

@ -89,11 +89,11 @@ class LinuxNetwork(Network):
locally_reachable_ips['ipv4'].append(address)
args = [ip_path, '-4', 'route', 'show', 'table', 'local']
rc, routes, _ = self.module.run_command(args)
rc, routes, dummy = self.module.run_command(args)
if rc == 0:
parse_locally_reachable_ips(routes)
args = [ip_path, '-6', 'route', 'show', 'table', 'local']
rc, routes, _ = self.module.run_command(args)
rc, routes, dummy = self.module.run_command(args)
if rc == 0:
parse_locally_reachable_ips(routes)
@ -274,7 +274,7 @@ class LinuxNetwork(Network):
elif words[0] == 'inet6':
if 'peer' == words[2]:
address = words[1]
_, prefix = words[3].split('/')
dummy, prefix = words[3].split('/')
scope = words[5]
else:
address, prefix = words[1].split('/')

@ -1497,7 +1497,7 @@ class Request:
login = None
if login:
username, _, password = login
username, dummy, password = login
if username and password:
headers["Authorization"] = basic_auth_header(username, password)

@ -689,7 +689,7 @@ def main():
b_mysrc = b_src
if remote_src and os.path.isfile(b_src):
_, b_mysrc = tempfile.mkstemp(dir=os.path.dirname(b_dest))
dummy, b_mysrc = tempfile.mkstemp(dir=os.path.dirname(b_dest))
shutil.copyfile(b_src, b_mysrc)
try:

@ -1124,7 +1124,7 @@ def create_archive(git_path, module, dest, archive, archive_prefix, version, rep
""" Helper function for creating archive using git_archive """
all_archive_fmt = {'.zip': 'zip', '.gz': 'tar.gz', '.tar': 'tar',
'.tgz': 'tgz'}
_, archive_ext = os.path.splitext(archive)
dummy, archive_ext = os.path.splitext(archive)
archive_fmt = all_archive_fmt.get(archive_ext, None)
if archive_fmt is None:
module.fail_json(msg="Unable to get file extension from "

@ -698,7 +698,7 @@ def push_arguments(iptables_path, action, params, make_rule=True):
def check_rule_present(iptables_path, module, params):
cmd = push_arguments(iptables_path, '-C', params)
rc, _, __ = module.run_command(cmd, check_rc=False)
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
return (rc == 0)
@ -732,7 +732,7 @@ def get_chain_policy(iptables_path, module, params):
cmd = push_arguments(iptables_path, '-L', params, make_rule=False)
if module.params['numeric']:
cmd.append('--numeric')
rc, out, _ = module.run_command(cmd, check_rc=True)
rc, out, err = module.run_command(cmd, check_rc=True)
chain_header = out.split("\n")[0]
result = re.search(r'\(policy ([A-Z]+)\)', chain_header)
if result:
@ -742,7 +742,7 @@ def get_chain_policy(iptables_path, module, params):
def get_iptables_version(iptables_path, module):
cmd = [iptables_path, '--version']
rc, out, _ = module.run_command(cmd, check_rc=True)
rc, out, err = module.run_command(cmd, check_rc=True)
return out.split('v')[1].rstrip('\n')
@ -755,7 +755,7 @@ def check_chain_present(iptables_path, module, params):
cmd = push_arguments(iptables_path, '-L', params, make_rule=False)
if module.params['numeric']:
cmd.append('--numeric')
rc, _, __ = module.run_command(cmd, check_rc=False)
rc, out, err = module.run_command(cmd, check_rc=False)
return (rc == 0)

@ -810,7 +810,7 @@ def main():
out_freeze_before = None
if requirements or has_vcs:
_, out_freeze_before, _ = _get_packages(module, pip, chdir)
dummy, out_freeze_before, dummy = _get_packages(module, pip, chdir)
rc, out_pip, err_pip = module.run_command(cmd, path_prefix=path_prefix, cwd=chdir)
out += out_pip
@ -827,7 +827,7 @@ def main():
if out_freeze_before is None:
changed = 'Successfully installed' in out_pip
else:
_, out_freeze_after, _ = _get_packages(module, pip, chdir)
dummy, out_freeze_after, dummy = _get_packages(module, pip, chdir)
changed = out_freeze_before != out_freeze_after
changed = changed or venv_created

@ -618,7 +618,7 @@ class YumModule(YumDnf):
if not repoq:
pkgs = []
try:
e, m, _ = self.yum_base.rpmdb.matchPackageNames([pkgspec])
e, m, dummy = self.yum_base.rpmdb.matchPackageNames([pkgspec])
pkgs = e + m
if not pkgs and not is_pkg:
pkgs.extend(self.yum_base.returnInstalledPackagesByDep(pkgspec))
@ -670,7 +670,7 @@ class YumModule(YumDnf):
pkgs = []
try:
e, m, _ = self.yum_base.pkgSack.matchPackageNames([pkgspec])
e, m, dummy = self.yum_base.pkgSack.matchPackageNames([pkgspec])
pkgs = e + m
if not pkgs:
pkgs.extend(self.yum_base.returnPackagesByDep(pkgspec))
@ -710,7 +710,7 @@ class YumModule(YumDnf):
pkgs = self.yum_base.returnPackagesByDep(pkgspec) + \
self.yum_base.returnInstalledPackagesByDep(pkgspec)
if not pkgs:
e, m, _ = self.yum_base.pkgSack.matchPackageNames([pkgspec])
e, m, dummy = self.yum_base.pkgSack.matchPackageNames([pkgspec])
pkgs = e + m
updates = self.yum_base.doPackageLists(pkgnarrow='updates').updates
except Exception as e:
@ -928,7 +928,7 @@ class YumModule(YumDnf):
cmd = repoq + ["--qf", qf, "-a"]
if self.releasever:
cmd.extend(['--releasever=%s' % self.releasever])
rc, out, _ = self.module.run_command(cmd)
rc, out, err = self.module.run_command(cmd)
if rc == 0:
return set(p for p in out.split('\n') if p.strip())
else:
@ -1419,7 +1419,7 @@ class YumModule(YumDnf):
# this contains the full NVR and spec could contain wildcards
# or virtual provides (like "python-*" or "smtp-daemon") while
# updates contains name only.
pkgname, _, _, _, _ = splitFilename(pkg)
(pkgname, ver, rel, epoch, arch) = splitFilename(pkg)
if spec in pkgs['update'] and pkgname in updates:
nothing_to_do = False
will_update.add(spec)

@ -787,13 +787,13 @@ class VaultEditor:
passes = 3
with open(tmp_path, "wb") as fh:
for _ in range(passes):
for dummy in range(passes):
fh.seek(0, 0)
# get a random chunk of data, each pass with other length
chunk_len = random.randint(max_chunk_len // 2, max_chunk_len)
data = os.urandom(chunk_len)
for _ in range(0, file_len // chunk_len):
for dummy in range(0, file_len // chunk_len):
fh.write(data)
fh.write(data[:file_len % chunk_len])

@ -637,7 +637,7 @@ class FieldAttributeBase:
else:
combined = value + new_value
return [i for i, _ in itertools.groupby(combined) if i is not None]
return [i for i, dummy in itertools.groupby(combined) if i is not None]
def dump_attrs(self):
'''

@ -288,7 +288,7 @@ def load_list_of_tasks(ds, play, block=None, role=None, task_include=None, use_h
ir._role_name = templar.template(ir._role_name)
# uses compiled list from object
blocks, _ = ir.get_block_list(variable_manager=variable_manager, loader=loader)
blocks, dummy = ir.get_block_list(variable_manager=variable_manager, loader=loader)
task_list.extend(blocks)
else:
# passes task object itself for latter generation of list

@ -175,7 +175,7 @@ class LookupModule(LookupBase):
if not match:
return False
_, start, end, _, stride, _, format = match.groups()
dummy, start, end, dummy, stride, dummy, format = match.groups()
if start is not None:
try:

@ -598,7 +598,7 @@ class StrategyBase:
else:
iterator.mark_host_failed(original_host)
state, _ = iterator.get_next_task_for_host(original_host, peek=True)
state, dummy = iterator.get_next_task_for_host(original_host, peek=True)
if iterator.is_failed(original_host) and state and state.run_state == IteratingStates.COMPLETE:
self._tqm._failed_hosts[original_host.name] = True

@ -77,7 +77,7 @@ class StrategyModule(StrategyBase):
if self._in_handlers and not any(filter(
lambda rs: rs == IteratingStates.HANDLERS,
(s.run_state for s, _ in state_task_per_host.values()))
(s.run_state for s, dummy in state_task_per_host.values()))
):
self._in_handlers = False
@ -361,7 +361,7 @@ class StrategyModule(StrategyBase):
if any_errors_fatal and (len(failed_hosts) > 0 or len(unreachable_hosts) > 0):
dont_fail_states = frozenset([IteratingStates.RESCUE, IteratingStates.ALWAYS])
for host in hosts_left:
(s, _) = iterator.get_next_task_for_host(host, peek=True)
(s, dummy) = iterator.get_next_task_for_host(host, peek=True)
# the state may actually be in a child state, use the get_active_state()
# method in the iterator to figure out the true active state
s = iterator.get_active_state(s)

@ -137,8 +137,7 @@ class HostVarsVars(Mapping):
def __getitem__(self, var):
templar = Templar(variables=self._vars, loader=self._loader)
foo = templar.template(self._vars[var], fail_on_undefined=False, static_vars=STATIC_VARS)
return foo
return templar.template(self._vars[var], fail_on_undefined=False, static_vars=STATIC_VARS)
def __contains__(self, var):
return (var in self._vars)

@ -6,11 +6,9 @@ examples/scripts/upgrade_to_ps3.ps1 pslint:PSCustomUseLiteralPath
examples/scripts/upgrade_to_ps3.ps1 pslint:PSUseApprovedVerbs
lib/ansible/cli/scripts/ansible_connection_cli_stub.py shebang
lib/ansible/config/base.yml no-unwanted-files
lib/ansible/executor/playbook_executor.py pylint:disallowed-name
lib/ansible/executor/powershell/async_watchdog.ps1 pslint:PSCustomUseLiteralPath
lib/ansible/executor/powershell/async_wrapper.ps1 pslint:PSCustomUseLiteralPath
lib/ansible/executor/powershell/exec_wrapper.ps1 pslint:PSCustomUseLiteralPath
lib/ansible/executor/task_queue_manager.py pylint:disallowed-name
lib/ansible/galaxy/collection/__init__.py mypy-3.9:attr-defined # inline ignore has no effect
lib/ansible/galaxy/collection/__init__.py mypy-3.10:attr-defined # inline ignore has no effect
lib/ansible/galaxy/collection/__init__.py mypy-3.11:attr-defined # inline ignore has no effect
@ -35,7 +33,6 @@ lib/ansible/modules/command.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/command.py validate-modules:doc-missing-type
lib/ansible/modules/command.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/command.py validate-modules:undocumented-parameter
lib/ansible/modules/copy.py pylint:disallowed-name
lib/ansible/modules/copy.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/copy.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/copy.py validate-modules:undocumented-parameter
@ -43,15 +40,12 @@ lib/ansible/modules/dnf.py validate-modules:parameter-invalid
lib/ansible/modules/dnf5.py validate-modules:parameter-invalid
lib/ansible/modules/file.py validate-modules:undocumented-parameter
lib/ansible/modules/find.py use-argspec-type-path # fix needed
lib/ansible/modules/git.py pylint:disallowed-name
lib/ansible/modules/git.py use-argspec-type-path
lib/ansible/modules/git.py validate-modules:doc-required-mismatch
lib/ansible/modules/iptables.py pylint:disallowed-name
lib/ansible/modules/lineinfile.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/lineinfile.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/lineinfile.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/package_facts.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/pip.py pylint:disallowed-name
lib/ansible/modules/replace.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/service.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/service.py validate-modules:use-run-command-not-popen
@ -65,7 +59,6 @@ lib/ansible/modules/sysvinit.py validate-modules:return-syntax-error
lib/ansible/modules/uri.py validate-modules:doc-required-mismatch
lib/ansible/modules/user.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/user.py validate-modules:use-run-command-not-popen
lib/ansible/modules/yum.py pylint:disallowed-name
lib/ansible/modules/yum.py validate-modules:parameter-invalid
lib/ansible/modules/yum_repository.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/yum_repository.py validate-modules:parameter-type-not-in-doc
@ -73,7 +66,6 @@ lib/ansible/modules/yum_repository.py validate-modules:undocumented-parameter
lib/ansible/module_utils/basic.py pylint:unused-import # deferring resolution to allow enabling the rule now
lib/ansible/module_utils/compat/_selectors2.py future-import-boilerplate # ignore bundled
lib/ansible/module_utils/compat/_selectors2.py metaclass-boilerplate # ignore bundled
lib/ansible/module_utils/compat/_selectors2.py pylint:disallowed-name
lib/ansible/module_utils/compat/selinux.py import-2.7!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.5!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.6!skip # pass/fail depends on presence of libselinux.so
@ -88,7 +80,6 @@ lib/ansible/module_utils/distro/_distro.py pylint:undefined-variable # ignore bu
lib/ansible/module_utils/distro/_distro.py pylint:using-constant-test # bundled code we don't want to modify
lib/ansible/module_utils/distro/__init__.py empty-init # breaks namespacing, bundled, do not override
lib/ansible/module_utils/facts/__init__.py empty-init # breaks namespacing, deprecate and eventually remove
lib/ansible/module_utils/facts/network/linux.py pylint:disallowed-name
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 pslint:PSUseApprovedVerbs
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 pslint:PSProvideCommentHelp # need to agree on best format for comment location
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.CommandUtil.psm1 pslint:PSUseApprovedVerbs
@ -109,13 +100,9 @@ lib/ansible/module_utils/six/__init__.py pylint:self-assigning-variable
lib/ansible/module_utils/six/__init__.py pylint:trailing-comma-tuple
lib/ansible/module_utils/six/__init__.py replace-urlopen
lib/ansible/module_utils/urls.py pylint:arguments-renamed
lib/ansible/module_utils/urls.py pylint:disallowed-name
lib/ansible/module_utils/urls.py replace-urlopen
lib/ansible/parsing/vault/__init__.py pylint:disallowed-name
lib/ansible/parsing/yaml/objects.py pylint:arguments-renamed
lib/ansible/playbook/base.py pylint:disallowed-name
lib/ansible/playbook/collectionsearch.py required-and-default-attributes # https://github.com/ansible/ansible/issues/61460
lib/ansible/playbook/helpers.py pylint:disallowed-name
lib/ansible/playbook/playbook_include.py pylint:arguments-renamed
lib/ansible/playbook/role/include.py pylint:arguments-renamed
lib/ansible/plugins/action/normal.py action-plugin-docs # default action plugin for modules without a dedicated action plugin
@ -124,13 +111,9 @@ lib/ansible/plugins/callback/__init__.py pylint:arguments-renamed
lib/ansible/plugins/inventory/advanced_host_list.py pylint:arguments-renamed
lib/ansible/plugins/inventory/host_list.py pylint:arguments-renamed
lib/ansible/plugins/lookup/random_choice.py pylint:arguments-renamed
lib/ansible/plugins/lookup/sequence.py pylint:disallowed-name
lib/ansible/plugins/shell/cmd.py pylint:arguments-renamed
lib/ansible/plugins/strategy/__init__.py pylint:disallowed-name
lib/ansible/plugins/strategy/linear.py pylint:disallowed-name
lib/ansible/utils/collection_loader/_collection_finder.py pylint:deprecated-class
lib/ansible/utils/collection_loader/_collection_meta.py pylint:deprecated-class
lib/ansible/vars/hostvars.py pylint:disallowed-name
test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py pylint:ansible-bad-function # ignore, required for testing
test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py pylint:ansible-bad-import-from # ignore, required for testing
test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py pylint:ansible-bad-import # ignore, required for testing
@ -220,20 +203,14 @@ test/support/windows-integration/plugins/modules/win_user_right.ps1 pslint!skip
test/support/windows-integration/plugins/modules/win_user.ps1 pslint!skip
test/support/windows-integration/plugins/modules/win_wait_for.ps1 pslint!skip
test/support/windows-integration/plugins/modules/win_whoami.ps1 pslint!skip
test/units/executor/test_play_iterator.py pylint:disallowed-name
test/units/modules/test_apt.py pylint:disallowed-name
test/units/module_utils/basic/test_deprecate_warn.py pylint:ansible-deprecated-no-version
test/units/module_utils/basic/test_deprecate_warn.py pylint:ansible-deprecated-version
test/units/module_utils/basic/test_run_command.py pylint:disallowed-name
test/units/module_utils/common/warnings/test_deprecate.py pylint:ansible-deprecated-no-version # testing Display.deprecated call without a version or date
test/units/module_utils/common/warnings/test_deprecate.py pylint:ansible-deprecated-version # testing Deprecated version found in call to Display.deprecated or AnsibleModule.deprecate
test/units/module_utils/urls/fixtures/multipart.txt line-endings # Fixture for HTTP tests that use CRLF
test/units/module_utils/urls/test_fetch_url.py replace-urlopen
test/units/module_utils/urls/test_gzip.py replace-urlopen
test/units/module_utils/urls/test_Request.py replace-urlopen
test/units/parsing/vault/test_vault.py pylint:disallowed-name
test/units/playbook/role/test_role.py pylint:disallowed-name
test/units/plugins/test_plugins.py pylint:disallowed-name
test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/action/my_action.py pylint:relative-beyond-top-level
test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/ansible/__init__.py empty-init # testing that collections don't need inits

@ -430,9 +430,9 @@ class TestPlayIterator(unittest.TestCase):
)
# iterate past first task
_, task = itr.get_next_task_for_host(hosts[0])
dummy, task = itr.get_next_task_for_host(hosts[0])
while (task and task.action != 'debug'):
_, task = itr.get_next_task_for_host(hosts[0])
dummy, task = itr.get_next_task_for_host(hosts[0])
self.assertIsNotNone(task, 'iterated past end of play while looking for place to insert tasks')

@ -194,7 +194,7 @@ class TestRunCommandPrompt:
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
def test_prompt_no_match(self, mocker, rc_am):
rc_am._os._cmd_out[mocker.sentinel.stdout] = BytesIO(b'hello')
(rc, _, _) = rc_am.run_command('foo', prompt_regex='[pP]assword:')
(rc, stdout, stderr) = rc_am.run_command('foo', prompt_regex='[pP]assword:')
assert rc == 0
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
@ -204,7 +204,7 @@ class TestRunCommandPrompt:
fh=mocker.sentinel.stdout),
mocker.sentinel.stderr:
SpecialBytesIO(b'', fh=mocker.sentinel.stderr)}
(rc, _, _) = rc_am.run_command('foo', prompt_regex=r'[pP]assword:', data=None)
(rc, stdout, stderr) = rc_am.run_command('foo', prompt_regex=r'[pP]assword:', data=None)
assert rc == 257
@ -212,7 +212,7 @@ class TestRunCommandRc:
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
def test_check_rc_false(self, rc_am):
rc_am._subprocess.Popen.return_value.returncode = 1
(rc, _, _) = rc_am.run_command('/bin/false', check_rc=False, prompt_regex='i_dont_exist')
(rc, stdout, stderr) = rc_am.run_command('/bin/false', check_rc=False, prompt_regex='i_dont_exist')
assert rc == 1
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])

@ -29,25 +29,25 @@ class AptExpandPkgspecTestCase(unittest.TestCase):
]
def test_trivial(self):
foo = ["apt"]
pkg = ["apt"]
self.assertEqual(
expand_pkgspec_from_fnmatches(None, foo, self.fake_cache), foo)
expand_pkgspec_from_fnmatches(None, pkg, self.fake_cache), pkg)
def test_version_wildcard(self):
foo = ["apt=1.0*"]
pkg = ["apt=1.0*"]
self.assertEqual(
expand_pkgspec_from_fnmatches(None, foo, self.fake_cache), foo)
expand_pkgspec_from_fnmatches(None, pkg, self.fake_cache), pkg)
def test_pkgname_wildcard_version_wildcard(self):
foo = ["apt*=1.0*"]
pkg = ["apt*=1.0*"]
m_mock = Mock()
self.assertEqual(
expand_pkgspec_from_fnmatches(m_mock, foo, self.fake_cache),
expand_pkgspec_from_fnmatches(m_mock, pkg, self.fake_cache),
['apt', 'apt-utils'])
def test_pkgname_expands(self):
foo = ["apt*"]
pkg = ["apt*"]
m_mock = Mock()
self.assertEqual(
expand_pkgspec_from_fnmatches(m_mock, foo, self.fake_cache),
expand_pkgspec_from_fnmatches(m_mock, pkg, self.fake_cache),
["apt", "apt-utils"])

@ -793,8 +793,8 @@ class TestVaultLib(unittest.TestCase):
3138'''
b_data = to_bytes(enc_data, errors='strict', encoding='utf-8')
b_data = self.v._split_header(b_data)
foo = binascii.unhexlify(b_data)
lines = foo.splitlines()
unhex_data = binascii.unhexlify(b_data)
lines = unhex_data.splitlines()
# line 0 is salt, line 1 is hmac, line 2+ is ciphertext
b_salt = lines[0]
b_hmac = lines[1]

@ -142,18 +142,18 @@ class TestHashParams(unittest.TestCase):
self.assertNotEqual(hash(res1), hash(res2))
self.assertNotEqual(res1, res2)
foo = {}
foo[res1] = 'params1'
foo[res2] = 'params2'
params_dict = {}
params_dict[res1] = 'params1'
params_dict[res2] = 'params2'
self.assertEqual(len(foo), 2)
self.assertEqual(len(params_dict), 2)
del foo[res2]
self.assertEqual(len(foo), 1)
del params_dict[res2]
self.assertEqual(len(params_dict), 1)
for key in foo:
self.assertTrue(key in foo)
self.assertIn(key, foo)
for key in params_dict:
self.assertTrue(key in params_dict)
self.assertIn(key, params_dict)
class TestRole(unittest.TestCase):

@ -46,14 +46,14 @@ class TestErrors(unittest.TestCase):
# python library, and then uses the __file__ attribute of
# the result for that to get the library path, so we mock
# that here and patch the builtin to use our mocked result
foo = MagicMock()
bar = MagicMock()
foo_pkg = MagicMock()
bar_pkg = MagicMock()
bam = MagicMock()
bam.__file__ = '/path/to/my/foo/bar/bam/__init__.py'
bar.bam = bam
foo.return_value.bar = bar
bar_pkg.bam = bam
foo_pkg.return_value.bar = bar_pkg
pl = PluginLoader('test', 'foo.bar.bam', 'test', 'test_plugin')
with patch('builtins.__import__', foo):
with patch('builtins.__import__', foo_pkg):
self.assertEqual(pl._get_package_paths(), ['/path/to/my/foo/bar/bam'])
def test_plugins__get_paths(self):

Loading…
Cancel
Save