From e907b0f04354873316311072da572943abb6281a Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Mon, 26 Sep 2022 13:00:56 +0200 Subject: Modernize via pyupgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Górny --- tests/keydata.py | 3 +-- tests/test_compression.py | 3 +-- tests/test_find_top_level.py | 3 +-- tests/test_hash.py | 3 +-- tests/test_manifest.py | 3 +-- tests/test_openpgp.py | 17 ++++++++--------- tests/test_profile.py | 16 ++++++---------- tests/test_recursiveloader.py | 22 ++++++++++------------ tests/test_util.py | 3 +-- tests/test_verify.py | 1 - tests/testutil.py | 9 ++++----- 11 files changed, 34 insertions(+), 49 deletions(-) (limited to 'tests') diff --git a/tests/keydata.py b/tests/keydata.py index 2f51af5..1be5fdb 100644 --- a/tests/keydata.py +++ b/tests/keydata.py @@ -1,6 +1,5 @@ # gemato: OpenPGP key data for tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import base64 diff --git a/tests/test_compression.py b/tests/test_compression.py index d5700e1..43e218e 100644 --- a/tests/test_compression.py +++ b/tests/test_compression.py @@ -1,6 +1,5 @@ # gemato: compressed file tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import base64 diff --git a/tests/test_find_top_level.py b/tests/test_find_top_level.py index 47b3f1e..aefa72d 100644 --- a/tests/test_find_top_level.py +++ b/tests/test_find_top_level.py @@ -1,6 +1,5 @@ # gemato: Top-level Manifest finding tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import gzip diff --git a/tests/test_hash.py b/tests/test_hash.py index e237ca4..1741b20 100644 --- a/tests/test_hash.py +++ b/tests/test_hash.py @@ -1,6 +1,5 @@ # gemato: hash support tests -# vim:fileencoding=utf-8 -# (c) 2017 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import io diff --git a/tests/test_manifest.py b/tests/test_manifest.py index 7bed4d5..81414d4 100644 --- a/tests/test_manifest.py +++ b/tests/test_manifest.py @@ -1,6 +1,5 @@ # gemato: Manifest file support tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import datetime diff --git a/tests/test_openpgp.py b/tests/test_openpgp.py index 602379e..e4f47e5 100644 --- a/tests/test_openpgp.py +++ b/tests/test_openpgp.py @@ -1,5 +1,4 @@ # gemato: OpenPGP signature support tests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license @@ -79,7 +78,7 @@ jCvJNJ7pU8YnJSRTQDH0PZEupAdzDU/AhGSrBz5+Jr7N0pQIxq4duE/Q -----END PGP PUBLIC KEY BLOCK----- ''' -SIGNED_MANIFEST = u''' +SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -106,7 +105,7 @@ mkkhTd2Auao4D2K74BePBuiZ9+eDQA== -----END PGP SIGNATURE----- ''' -DASH_ESCAPED_SIGNED_MANIFEST = u''' +DASH_ESCAPED_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -133,7 +132,7 @@ mkkhTd2Auao4D2K74BePBuiZ9+eDQA== -----END PGP SIGNATURE----- ''' -MODIFIED_SIGNED_MANIFEST = u''' +MODIFIED_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -159,7 +158,7 @@ mkkhTd2Auao4D2K74BePBuiZ9+eDQA== -----END PGP SIGNATURE----- ''' -EXPIRED_SIGNED_MANIFEST = u''' +EXPIRED_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -201,7 +200,7 @@ VALID_KEY_SUBKEY = (PUBLIC_KEY + UID + PUBLIC_KEY_SIG + PUBLIC_SUBKEY + SUBKEY_FINGERPRINT = '7E9DDE3CBE47E437418DF74038B9D2F76CC833CC' SUBKEY_SIG_TIMESTAMP = datetime.datetime(2020, 8, 25, 12, 40, 12) -SUBKEY_SIGNED_MANIFEST = u''' +SUBKEY_SIGNED_MANIFEST = ''' -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 @@ -317,7 +316,7 @@ def test_noverify_recursive_manifest_loader(tmp_path, write_back): if write_back: m.save_manifest('Manifest') - with open(tmp_path / 'Manifest', 'r') as f: + with open(tmp_path / 'Manifest') as f: assert f.read() == strip_openpgp(MODIFIED_SIGNED_MANIFEST) @@ -651,7 +650,7 @@ def privkey_env(request): env.close() -TEST_STRING = u'The quick brown fox jumps over the lazy dog' +TEST_STRING = 'The quick brown fox jumps over the lazy dog' @pytest.mark.parametrize('keyid', [None, PRIVATE_KEY_ID]) @@ -729,7 +728,7 @@ def test_recursive_manifest_loader_save_submanifest(tmp_path, privkey_env): m.save_manifest('eclass/Manifest') m2 = ManifestFile() - with open(tmp_path / 'eclass' / 'Manifest', 'r') as f: + with open(tmp_path / 'eclass' / 'Manifest') as f: m2.load(f, openpgp_env=privkey_env) assert not m2.openpgp_signed assert m2.openpgp_signature is None diff --git a/tests/test_profile.py b/tests/test_profile.py index 1d15561..1d4a7df 100644 --- a/tests/test_profile.py +++ b/tests/test_profile.py @@ -1,6 +1,5 @@ # gemato: Profile behavior tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import itertools @@ -196,8 +195,7 @@ def test_update_entries_for_directory(test_repo, profile): for path in EXPECTED_MANIFESTS + PACKAGE_MANIFESTS] + [(path, make_expect_match(path, 'IGNORE')) for path in EXPECTED_IGNORE]) - found = dict((path, make_entry_match(m, path)) - for path in expected) + found = {path: make_entry_match(m, path) for path in expected} assert found == expected m.save_manifests() @@ -208,8 +206,8 @@ def test_update_entries_for_directory(test_repo, profile): ((path + PKG_MANIFEST_SUFFIX[profile], make_expect_match(path, 'MANIFEST')) for path in PACKAGE_MANIFESTS))) - manifests_found = dict((path, make_entry_match(m, path)) - for path in manifests_expected) + manifests_found = {path: make_entry_match(m, path) + for path in manifests_expected} assert manifests_found == manifests_expected m.assert_directory_verifies('') @@ -232,8 +230,7 @@ def test_cli_update(test_repo, profile): for path in PACKAGE_MANIFESTS] + [(path, make_expect_match(path, 'IGNORE')) for path in EXPECTED_IGNORE]) - found = dict((path, make_entry_match(m, path)) - for path in expected) + found = {path: make_entry_match(m, path) for path in expected} assert found == expected assert gemato.cli.main(['gemato', 'verify', str(test_repo)]) == 0 @@ -266,6 +263,5 @@ def test_regression_top_level_ignore_in_all_manifests(test_repo, profile): 'dev-foo/Manifest': ('MANIFEST', False), 'dev-foo/distfiles': None, } - found = dict((path, make_entry_match(m, path)) - for path in expected) + found = {path: make_entry_match(m, path) for path in expected} assert found == expected diff --git a/tests/test_recursiveloader.py b/tests/test_recursiveloader.py index f0c5673..4a562bd 100644 --- a/tests/test_recursiveloader.py +++ b/tests/test_recursiveloader.py @@ -1,5 +1,4 @@ # gemato: Recursive loader tests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license @@ -633,7 +632,7 @@ MD5 d41d8cd98f00b204e9800998ecf8427e FILENAME: '', } - MANIFESTS_REWRITTEN = dict((k, v.lstrip()) for k, v in MANIFESTS.items()) + MANIFESTS_REWRITTEN = {k: v.lstrip() for k, v in MANIFESTS.items()} class FilenameBackslashLayout(BaseLayout): @@ -647,7 +646,7 @@ DATA foo\\x5Cbar 0 MD5 d41d8cd98f00b204e9800998ecf8427e FILENAME: '', } - MANIFESTS_REWRITTEN = dict((k, v.lstrip()) for k, v in MANIFESTS.items()) + MANIFESTS_REWRITTEN = {k: v.lstrip() for k, v in MANIFESTS.items()} class NewManifestLayout(BaseLayout): @@ -1208,10 +1207,9 @@ def test_get_file_entry_dict(layout_factory, layout, path, only_types, if only_types is not None: only_types = [only_types] entries = m.get_file_entry_dict(path, only_types=only_types) - assert (dict((subdir, dict((k, get_entry(v)) - for k, v in files.items())) - for subdir, files in entries.items()) == - expected) + assert ({subdir: {k: get_entry(v) for k, v in files.items()} + for subdir, files in entries.items() + } == expected) @pytest.mark.parametrize( @@ -1275,8 +1273,8 @@ def test_get_deduplicated_file_entry_dict_for_update(layout_factory, m = ManifestRecursiveLoader(tmp_path / layout.TOP_MANIFEST, allow_xdev=False) entries = m.get_deduplicated_file_entry_dict_for_update(path) - assert dict((k, (v[0],) + get_entry(v[1])) - for k, v in entries.items()) == expected + assert {k: (v[0],) + get_entry(v[1]) + for k, v in entries.items()} == expected @pytest.mark.parametrize( @@ -2056,7 +2054,7 @@ def test_update_entry_new_aux(layout_factory): assert (get_entry(m.find_path_entry('files/test.patch')) == ('AUX', 'files/test.patch', ['MD5'])) m.save_manifests() - with open(tmp_path / layout.TOP_MANIFEST, 'r') as f: + with open(tmp_path / layout.TOP_MANIFEST) as f: contents = f.read() assert (contents == 'AUX test.patch 0 MD5 d41d8cd98f00b204e9800998ecf8427e\n') @@ -2155,7 +2153,7 @@ def test_cli_update(layout_factory, layout, args, update, if replace_timestamp is not None: m = gemato.manifest.ManifestFile() - with open(tmp_path / layout.TOP_MANIFEST, 'r') as f: + with open(tmp_path / layout.TOP_MANIFEST) as f: m.load(f) ts = m.find_timestamp() assert ts is not None @@ -2362,7 +2360,7 @@ def test_new_manifest_cli(layout_factory, args): assert gemato.cli.main(['gemato', 'create', '--hashes=MD5'] + args.split() + [str(tmp_path)]) == 0 - with open(tmp_path / 'Manifest', 'r') as f: + with open(tmp_path / 'Manifest') as f: contents = f.read() expected = ''' DATA test 0 MD5 d41d8cd98f00b204e9800998ecf8427e diff --git a/tests/test_util.py b/tests/test_util.py index e802ea9..7a0974f 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,6 +1,5 @@ # gemato: Utility function tests -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import pytest diff --git a/tests/test_verify.py b/tests/test_verify.py index 0c3fba9..32e30c8 100644 --- a/tests/test_verify.py +++ b/tests/test_verify.py @@ -1,5 +1,4 @@ # gemato: Verification tests -# vim:fileencoding=utf-8 # (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license diff --git a/tests/testutil.py b/tests/testutil.py index bde84f7..2becb23 100644 --- a/tests/testutil.py +++ b/tests/testutil.py @@ -1,6 +1,5 @@ # gemato: Test utility functions -# vim:fileencoding=utf-8 -# (c) 2017-2020 Michał Górny +# (c) 2017-2022 Michał Górny # Licensed under the terms of 2-clause BSD license import errno @@ -49,17 +48,17 @@ class TempDirTestCase(LoggingTestCase): FILES = {} def setUp(self): - super(TempDirTestCase, self).setUp() + super().setUp() self.dir = tempfile.mkdtemp() for k in self.DIRS: os.mkdir(os.path.join(self.dir, k)) for k, v in self.FILES.items(): - with io.open(os.path.join(self.dir, k), 'w', encoding='utf8') as f: + with open(os.path.join(self.dir, k), 'w', encoding='utf8') as f: f.write(v) def tearDown(self): shutil.rmtree(self.dir) - super(TempDirTestCase, self).tearDown() + super().tearDown() class HKPServerRequestHandler(BaseHTTPRequestHandler): -- cgit v1.2.3