From 11b9bc5cb5efd5cafd9fe4cf7a99a1252213025b Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 23 Nov 2021 15:56:09 -0500 Subject: Remove some more py27-isms (#1062) --- tests/test_crypto.py | 30 +++++++++++++++--------------- tests/test_ssl.py | 14 +++++++------- 2 files changed, 22 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/test_crypto.py b/tests/test_crypto.py index ef3429d..1172e79 100644 --- a/tests/test_crypto.py +++ b/tests/test_crypto.py @@ -2467,7 +2467,7 @@ class TestPKCS12(object): b"-nodes", b"-passin", b"pass:" + passwd, - *extra + *extra, ) assert recovered_key[-len(key) :] == key if cert: @@ -2479,7 +2479,7 @@ class TestPKCS12(object): b"-passin", b"pass:" + passwd, b"-nokeys", - *extra + *extra, ) assert recovered_cert[-len(cert) :] == cert if ca: @@ -2491,7 +2491,7 @@ class TestPKCS12(object): b"-passin", b"pass:" + passwd, b"-nokeys", - *extra + *extra, ) assert recovered_cert[-len(ca) :] == ca @@ -3477,7 +3477,7 @@ class TestRevoked(object): revoked.set_reason(None) assert revoked.get_reason() is None - @pytest.mark.parametrize("reason", [object(), 1.0, u"foo"]) + @pytest.mark.parametrize("reason", [object(), 1.0, "foo"]) def test_set_reason_wrong_args(self, reason): """ `Revoked.set_reason` raises `TypeError` if called with an argument @@ -3553,12 +3553,12 @@ class TestCRL(object): assert revoked is not None assert crl.issuer == x509.Name( [ - x509.NameAttribute(x509.NameOID.COUNTRY_NAME, u"US"), - x509.NameAttribute(x509.NameOID.STATE_OR_PROVINCE_NAME, u"IL"), - x509.NameAttribute(x509.NameOID.LOCALITY_NAME, u"Chicago"), - x509.NameAttribute(x509.NameOID.ORGANIZATION_NAME, u"Testing"), + x509.NameAttribute(x509.NameOID.COUNTRY_NAME, "US"), + x509.NameAttribute(x509.NameOID.STATE_OR_PROVINCE_NAME, "IL"), + x509.NameAttribute(x509.NameOID.LOCALITY_NAME, "Chicago"), + x509.NameAttribute(x509.NameOID.ORGANIZATION_NAME, "Testing"), x509.NameAttribute( - x509.NameOID.COMMON_NAME, u"Testing Root CA" + x509.NameOID.COMMON_NAME, "Testing Root CA" ), ] ) @@ -3580,12 +3580,12 @@ class TestCRL(object): assert revoked is not None assert crl.issuer == x509.Name( [ - x509.NameAttribute(x509.NameOID.COUNTRY_NAME, u"US"), - x509.NameAttribute(x509.NameOID.STATE_OR_PROVINCE_NAME, u"IL"), - x509.NameAttribute(x509.NameOID.LOCALITY_NAME, u"Chicago"), - x509.NameAttribute(x509.NameOID.ORGANIZATION_NAME, u"Testing"), + x509.NameAttribute(x509.NameOID.COUNTRY_NAME, "US"), + x509.NameAttribute(x509.NameOID.STATE_OR_PROVINCE_NAME, "IL"), + x509.NameAttribute(x509.NameOID.LOCALITY_NAME, "Chicago"), + x509.NameAttribute(x509.NameOID.ORGANIZATION_NAME, "Testing"), x509.NameAttribute( - x509.NameOID.COMMON_NAME, u"Testing Root CA" + x509.NameOID.COMMON_NAME, "Testing Root CA" ), ] ) @@ -4375,7 +4375,7 @@ class TestEllipticCurve(object): does not identify a supported curve. """ with pytest.raises(ValueError): - get_elliptic_curve(u"this curve was just invented") + get_elliptic_curve("this curve was just invented") def test_repr(self): """ diff --git a/tests/test_ssl.py b/tests/test_ssl.py index 05aeeee..3e424b6 100644 --- a/tests/test_ssl.py +++ b/tests/test_ssl.py @@ -454,10 +454,10 @@ def ca_file(tmpdir): builder = x509.CertificateBuilder() builder = builder.subject_name( - x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, u"pyopenssl.org")]) + x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "pyopenssl.org")]) ) builder = builder.issuer_name( - x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, u"pyopenssl.org")]) + x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, "pyopenssl.org")]) ) one_day = datetime.timedelta(1, 0, 0) builder = builder.not_valid_before(datetime.datetime.today() - one_day) @@ -498,7 +498,7 @@ class TestContext(object): @pytest.mark.parametrize( "cipher_string", - [b"hello world:AES128-SHA", u"hello world:AES128-SHA"], + [b"hello world:AES128-SHA", "hello world:AES128-SHA"], ) def test_set_cipher_list(self, context, cipher_string): """ @@ -588,7 +588,7 @@ class TestContext(object): `Context.set_session_id` raises a warning if a unicode string is passed. """ - pytest.deprecated_call(context.set_session_id, u"abc") + pytest.deprecated_call(context.set_session_id, "abc") def test_method(self): """ @@ -1708,7 +1708,7 @@ class TestContext(object): """ context = Context(SSLv23_METHOD) for curve in get_elliptic_curves(): - if curve.name.startswith(u"Oakley-"): + if curve.name.startswith("Oakley-"): # Setting Oakley-EC2N-4 and Oakley-EC2N-3 adds # ('bignum routines', 'BN_mod_inverse', 'no inverse') to the # error queue on OpenSSL 1.0.2. @@ -2068,7 +2068,7 @@ class TestApplicationLayerProtoNegotiation(object): def invalid_cb(conn, options): invalid_cb_args.append((conn, options)) - return u"can't return unicode" + return "can't return unicode" client_context = Context(SSLv23_METHOD) client_context.set_alpn_protos([b"http/1.1", b"spdy/2"]) @@ -2235,7 +2235,7 @@ class TestConnection(object): connection.bio_write(b"xy") connection.bio_write(bytearray(b"za")) with pytest.warns(DeprecationWarning): - connection.bio_write(u"deprecated") + connection.bio_write("deprecated") def test_get_context(self): """ -- cgit v1.2.1