1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-07 20:47:16 +00:00

batch 2 - update Python idiom to 3.7 using pyupgrade (#11342)

* batch 2 - update Python idiom to 3.7 using pyupgrade

* Apply suggestions from code review
This commit is contained in:
Alexei Znamensky 2025-12-30 22:50:16 +13:00 committed by GitHub
parent 9e363c9f94
commit 266d9d3fb0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 64 additions and 70 deletions

View file

@ -82,7 +82,7 @@ class TestInterfacesFileModule(unittest.TestCase):
with open(testfilepath, "wb") as f:
f.write(string.encode())
else:
with open(testfilepath, "r") as goldenfile:
with open(testfilepath) as goldenfile:
goldenData = json.load(goldenfile)
self.assertEqual(goldenData, ifaces)
@ -96,7 +96,7 @@ class TestInterfacesFileModule(unittest.TestCase):
f.write(string.encode())
f.close()
else:
with open(testfilepath, "r") as goldenfile:
with open(testfilepath) as goldenfile:
goldenstring = goldenfile.read()
goldenfile.close()
self.assertEqual(goldenstring, string)

View file

@ -245,9 +245,7 @@ class TestPermanentParams(ModuleTestCase):
with patch("ansible_collections.community.general.plugins.modules.modprobe.Modprobe.modprobe_files"):
modprobe.modprobe_files = ["/etc/modprobe.d/dummy1.conf", "/etc/modprobe.d/dummy2.conf"]
assert modprobe.permanent_params == set(
["numdummies=4", "dummy_parameter1=6", "dummy_parameter2=5"]
)
assert modprobe.permanent_params == {"numdummies=4", "dummy_parameter1=6", "dummy_parameter2=5"}
def test_module_permanent_params_empty(self):
files_content = ["", ""]

View file

@ -44,7 +44,7 @@ valid_inventory = {
"sed": "4.8-1",
"sqlite": "3.36.0-1",
},
"installed_groups": {"base-devel": set(["gawk", "grep", "file", "findutils", "pacman", "sed", "gzip", "gettext"])},
"installed_groups": {"base-devel": {"gawk", "grep", "file", "findutils", "pacman", "sed", "gzip", "gettext"}},
"available_pkgs": {
"acl": "2.3.1-1",
"amd-ucode": "20211027.1d00989-1",
@ -61,35 +61,33 @@ valid_inventory = {
"sudo": "1.9.8.p2-3",
},
"available_groups": {
"base-devel": set(
[
"libtool",
"gawk",
"which",
"texinfo",
"fakeroot",
"grep",
"findutils",
"autoconf",
"gzip",
"pkgconf",
"flex",
"patch",
"groff",
"m4",
"bison",
"gcc",
"gettext",
"make",
"file",
"pacman",
"sed",
"automake",
"sudo",
"binutils",
]
),
"some-group": set(["libtool", "sudo", "binutils"]),
"base-devel": {
"libtool",
"gawk",
"which",
"texinfo",
"fakeroot",
"grep",
"findutils",
"autoconf",
"gzip",
"pkgconf",
"flex",
"patch",
"groff",
"m4",
"bison",
"gcc",
"gettext",
"make",
"file",
"pacman",
"sed",
"automake",
"sudo",
"binutils",
},
"some-group": {"libtool", "sudo", "binutils"},
},
"upgradable_pkgs": {
"sqlite": VersionTuple(current="3.36.0-1", latest="3.37.0-1"),

View file

@ -34,7 +34,7 @@ class UTHelper:
for ext in extensions:
test_spec_filename = test_module.__file__.replace(".py", ext)
if os.path.exists(test_spec_filename):
with open(test_spec_filename, "r") as test_spec_filehandle:
with open(test_spec_filename) as test_spec_filehandle:
return UTHelper.from_file(ansible_module, test_module, test_spec_filehandle, mocks=mocks)
raise Exception(