Skip to content

Commit ece2267

Browse files
committed
lint: Rename self to cls in class methods
Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent b1b9c30 commit ece2267

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

tests/test_gpg.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class TestCommon(unittest.TestCase):
194194
"""Test common functions of the securesystemslib._gpg module."""
195195

196196
@classmethod
197-
def setUpClass(self):
197+
def setUpClass(cls):
198198
gpg_keyring_path = os.path.join(
199199
os.path.dirname(os.path.realpath(__file__)), "gpg_keyrings", "rsa"
200200
)
@@ -208,9 +208,9 @@ def setUpClass(self):
208208
with open(path, "rb") as f:
209209
data[keyid] = f.read()
210210

211-
self.raw_key_data = data[key]
212-
self.raw_key_bundle = parse_pubkey_bundle(data[key])
213-
self.raw_expired_key_bundle = parse_pubkey_bundle(data[key_expired])
211+
cls.raw_key_data = data[key]
212+
cls.raw_key_bundle = parse_pubkey_bundle(data[key])
213+
cls.raw_expired_key_bundle = parse_pubkey_bundle(data[key_expired])
214214

215215
def test_parse_pubkey_payload_errors(self):
216216
"""Test parse_pubkey_payload errors with manually crafted data."""
@@ -541,25 +541,25 @@ class TestGPGRSA(unittest.TestCase):
541541
keyid_768C43 = "7B3ABB26B97B655AB9296BD15B0BD02E1C768C43" # noqa: N815
542542

543543
@classmethod
544-
def setUpClass(self):
544+
def setUpClass(cls):
545545
# Create directory to run the tests without having everything blow up
546-
self.working_dir = os.getcwd()
546+
cls.working_dir = os.getcwd()
547547

548548
# Find demo files
549549
gpg_keyring_path = os.path.join(
550550
os.path.dirname(os.path.realpath(__file__)), "gpg_keyrings", "rsa"
551551
)
552552

553-
self.test_dir = os.path.realpath(tempfile.mkdtemp())
554-
self.gnupg_home = "rsa"
555-
shutil.copytree(gpg_keyring_path, os.path.join(self.test_dir, self.gnupg_home))
556-
os.chdir(self.test_dir)
553+
cls.test_dir = os.path.realpath(tempfile.mkdtemp())
554+
cls.gnupg_home = "rsa"
555+
shutil.copytree(gpg_keyring_path, os.path.join(cls.test_dir, cls.gnupg_home))
556+
os.chdir(cls.test_dir)
557557

558558
@classmethod
559-
def tearDownClass(self):
559+
def tearDownClass(cls):
560560
"""Change back to initial working dir and remove temp test directory."""
561-
os.chdir(self.working_dir)
562-
shutil.rmtree(self.test_dir, onerror=GPGTestUtils.ignore_not_found_error)
561+
os.chdir(cls.working_dir)
562+
shutil.rmtree(cls.test_dir, onerror=GPGTestUtils.ignore_not_found_error)
563563

564564
def test_export_pubkey_error(self):
565565
"""Test correct error is raised if function called incorrectly."""
@@ -705,25 +705,25 @@ class TestGPGDSA(unittest.TestCase):
705705
default_keyid = "C242A830DAAF1C2BEF604A9EF033A3A3E267B3B1"
706706

707707
@classmethod
708-
def setUpClass(self):
708+
def setUpClass(cls):
709709
# Create directory to run the tests without having everything blow up
710-
self.working_dir = os.getcwd()
711-
self.test_dir = os.path.realpath(tempfile.mkdtemp())
712-
self.gnupg_home = "dsa"
710+
cls.working_dir = os.getcwd()
711+
cls.test_dir = os.path.realpath(tempfile.mkdtemp())
712+
cls.gnupg_home = "dsa"
713713

714714
# Find keyrings
715715
keyrings = os.path.join(
716716
os.path.dirname(os.path.realpath(__file__)), "gpg_keyrings", "dsa"
717717
)
718718

719-
shutil.copytree(keyrings, os.path.join(self.test_dir, self.gnupg_home))
720-
os.chdir(self.test_dir)
719+
shutil.copytree(keyrings, os.path.join(cls.test_dir, cls.gnupg_home))
720+
os.chdir(cls.test_dir)
721721

722722
@classmethod
723-
def tearDownClass(self):
723+
def tearDownClass(cls):
724724
"""Change back to initial working dir and remove temp test directory."""
725-
os.chdir(self.working_dir)
726-
shutil.rmtree(self.test_dir, onerror=GPGTestUtils.ignore_not_found_error)
725+
os.chdir(cls.working_dir)
726+
shutil.rmtree(cls.test_dir, onerror=GPGTestUtils.ignore_not_found_error)
727727

728728
def test_export_pubkey(self):
729729
"""export a public key and make sure the parameters are the right ones:
@@ -796,25 +796,25 @@ class TestGPGEdDSA(unittest.TestCase):
796796
default_keyid = "4E630F84838BF6F7447B830B22692F5FEA9E2DD2"
797797

798798
@classmethod
799-
def setUpClass(self):
799+
def setUpClass(cls):
800800
# Create directory to run the tests without having everything blow up
801-
self.working_dir = os.getcwd()
802-
self.test_dir = os.path.realpath(tempfile.mkdtemp())
803-
self.gnupg_home = "dsa"
801+
cls.working_dir = os.getcwd()
802+
cls.test_dir = os.path.realpath(tempfile.mkdtemp())
803+
cls.gnupg_home = "dsa"
804804

805805
# Find keyrings
806806
keyrings = os.path.join(
807807
os.path.dirname(os.path.realpath(__file__)), "gpg_keyrings", "eddsa"
808808
)
809809

810-
shutil.copytree(keyrings, os.path.join(self.test_dir, self.gnupg_home))
811-
os.chdir(self.test_dir)
810+
shutil.copytree(keyrings, os.path.join(cls.test_dir, cls.gnupg_home))
811+
os.chdir(cls.test_dir)
812812

813813
@classmethod
814-
def tearDownClass(self):
814+
def tearDownClass(cls):
815815
"""Change back to initial working dir and remove temp test directory."""
816-
os.chdir(self.working_dir)
817-
shutil.rmtree(self.test_dir, onerror=GPGTestUtils.ignore_not_found_error)
816+
os.chdir(cls.working_dir)
817+
shutil.rmtree(cls.test_dir, onerror=GPGTestUtils.ignore_not_found_error)
818818

819819
def test_gpg_sign_and_verify_object_with_default_key(self):
820820
"""Create a signature using the default key on the keyring"""

0 commit comments

Comments
 (0)