mirror of
https://github.com/ansible-collections/community.crypto.git
synced 2026-03-26 21:33:25 +00:00
Replace % and str.format() with f-strings (#875)
* Replace % and str.format() with f-strings. * Apply suggestions from review.
This commit is contained in:
@@ -78,7 +78,7 @@ TEST_CASES = [
|
||||
@pytest.mark.parametrize("value, expected", TEST_CASES)
|
||||
def test_serialize_asn1_string_as_der(value, expected):
|
||||
actual = serialize_asn1_string_as_der(value)
|
||||
print("%s | %s" % (value, base64.b16encode(actual).decode()))
|
||||
print(f"{value} | {base64.b16encode(actual).decode()}")
|
||||
assert actual == expected
|
||||
|
||||
|
||||
@@ -121,10 +121,8 @@ def test_test_cases(value, expected, tmp_path):
|
||||
b_data = fd.read()
|
||||
|
||||
hex_str = base64.b16encode(b_data).decode().lower()
|
||||
print(
|
||||
"%s | \\x%s"
|
||||
% (value, "\\x".join([hex_str[i : i + 2] for i in range(0, len(hex_str), 2)]))
|
||||
)
|
||||
value = "\\x".join([hex_str[i : i + 2] for i in range(0, len(hex_str), 2)])
|
||||
print(f"{value} | \\x{value}")
|
||||
|
||||
# This is a know edge case where openssl asn1parse does not work properly.
|
||||
if value != "UTF8:café":
|
||||
|
||||
@@ -201,7 +201,7 @@ if (
|
||||
],
|
||||
)
|
||||
def test_parse_dn_component_failure(name, options, message):
|
||||
with pytest.raises(OpenSSLObjectError, match="^%s$" % re.escape(message)):
|
||||
with pytest.raises(OpenSSLObjectError, match=f"^{re.escape(message)}$"):
|
||||
_parse_dn_component(name, **options)
|
||||
|
||||
|
||||
@@ -245,5 +245,5 @@ def test_parse_dn(name, expected):
|
||||
],
|
||||
)
|
||||
def test_parse_dn_failure(name, message):
|
||||
with pytest.raises(OpenSSLObjectError, match="^%s$" % re.escape(message)):
|
||||
with pytest.raises(OpenSSLObjectError, match=f"^{re.escape(message)}$"):
|
||||
_parse_dn(name)
|
||||
|
||||
@@ -144,7 +144,7 @@ def test_default_key_params(keytype, size, passphrase, comment):
|
||||
"ed25519": 256,
|
||||
}
|
||||
|
||||
default_comment = "%s@%s" % (getuser(), gethostname())
|
||||
default_comment = f"{getuser()}@{gethostname()}"
|
||||
pair = OpensshKeypair.generate(
|
||||
keytype=keytype, size=size, passphrase=passphrase, comment=comment
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user