Mercurial > public > mercurial-scm > hg-stable
diff tests/test-url.py @ 52664:9db77d46de79
py3: drop redundant `u''` prefixes on string literals
Strings are unicode on Python 3. These were rewritten by `pyupgrade`.
It's arguably better to fix the `contrib` stuff upstream and then re-vendor it,
but I don't feel like waiting for that, and then all of the regression testing
involved to get a minor improvement in the codebase. It was last vendored 5
years ago, and will likely be a large change anyway to drop py2 support. Also,
we've already made minor formatting changes to it locally.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 06 Jan 2025 14:15:40 -0500 |
parents | 6000f5b25c9b |
children | f19a3f1437f3 |
line wrap: on
line diff
--- a/tests/test-url.py Mon Jan 06 14:07:43 2025 -0500 +++ b/tests/test-url.py Mon Jan 06 14:15:40 2025 -0500 @@ -69,7 +69,7 @@ # Unicode (IDN) certname isn't supported check( - _verifycert(cert(u'\u4f8b.jp'), 'example.jp'), + _verifycert(cert('\u4f8b.jp'), 'example.jp'), b'IDN in certificate not supported', ) @@ -137,7 +137,7 @@ check(_verifycert(cert('a.*.com'), 'a.com'), b'certificate is for a.*.com') # wildcard doesn't match IDNA prefix 'xn--' -idna = u'püthon.python.org'.encode('idna').decode('ascii') +idna = 'püthon.python.org'.encode('idna').decode('ascii') check(_verifycert(cert(idna), idna), None) check( _verifycert(cert('x*.python.org'), idna), @@ -150,27 +150,27 @@ # wildcard in first fragment and IDNA A-labels in sequent fragments # are supported. -idna = u'www*.pythön.org'.encode('idna').decode('ascii') +idna = 'www*.pythön.org'.encode('idna').decode('ascii') check( - _verifycert(cert(idna), u'www.pythön.org'.encode('idna').decode('ascii')), + _verifycert(cert(idna), 'www.pythön.org'.encode('idna').decode('ascii')), None, ) check( - _verifycert(cert(idna), u'www1.pythön.org'.encode('idna').decode('ascii')), + _verifycert(cert(idna), 'www1.pythön.org'.encode('idna').decode('ascii')), None, ) check( - _verifycert(cert(idna), u'ftp.pythön.org'.encode('idna').decode('ascii')), + _verifycert(cert(idna), 'ftp.pythön.org'.encode('idna').decode('ascii')), b'certificate is for www*.xn--pythn-mua.org', ) check( - _verifycert(cert(idna), u'pythön.org'.encode('idna').decode('ascii')), + _verifycert(cert(idna), 'pythön.org'.encode('idna').decode('ascii')), b'certificate is for www*.xn--pythn-mua.org', ) c = { 'notAfter': 'Jun 26 21:41:46 2011 GMT', - 'subject': (((u'commonName', u'linuxfrz.org'),),), + 'subject': ((('commonName', 'linuxfrz.org'),),), 'subjectAltName': ( ('DNS', 'linuxfr.org'), ('DNS', 'linuxfr.com'), @@ -194,11 +194,11 @@ c = { 'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ( - ((u'countryName', u'US'),), - ((u'stateOrProvinceName', u'California'),), - ((u'localityName', u'Mountain View'),), - ((u'organizationName', u'Google Inc'),), - ((u'commonName', u'mail.google.com'),), + (('countryName', 'US'),), + (('stateOrProvinceName', 'California'),), + (('localityName', 'Mountain View'),), + (('organizationName', 'Google Inc'),), + (('commonName', 'mail.google.com'),), ), } check(_verifycert(c, 'mail.google.com'), None) @@ -211,10 +211,10 @@ c = { 'notAfter': 'Dec 18 23:59:59 2011 GMT', 'subject': ( - ((u'countryName', u'US'),), - ((u'stateOrProvinceName', u'California'),), - ((u'localityName', u'Mountain View'),), - ((u'organizationName', u'Google Inc'),), + (('countryName', 'US'),), + (('stateOrProvinceName', 'California'),), + (('localityName', 'Mountain View'),), + (('organizationName', 'Google Inc'),), ), } check( @@ -226,10 +226,10 @@ c = { 'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ( - ((u'countryName', u'US'),), - ((u'stateOrProvinceName', u'California'),), - ((u'localityName', u'Mountain View'),), - ((u'commonName', u'mail.google.com'),), + (('countryName', 'US'),), + (('stateOrProvinceName', 'California'),), + (('localityName', 'Mountain View'),), + (('commonName', 'mail.google.com'),), ), 'subjectAltName': (('othername', 'blabla'),), } @@ -239,10 +239,10 @@ c = { 'notAfter': 'Dec 18 23:59:59 2099 GMT', 'subject': ( - ((u'countryName', u'US'),), - ((u'stateOrProvinceName', u'California'),), - ((u'localityName', u'Mountain View'),), - ((u'organizationName', u'Google Inc'),), + (('countryName', 'US'),), + (('stateOrProvinceName', 'California'),), + (('localityName', 'Mountain View'),), + (('organizationName', 'Google Inc'),), ), 'subjectAltName': (('othername', 'blabla'),), } @@ -258,15 +258,15 @@ # avoid denials of service by refusing more than one # wildcard per fragment. check( - _verifycert({'subject': (((u'commonName', u'a*b.com'),),)}, 'axxb.com'), + _verifycert({'subject': ((('commonName', 'a*b.com'),),)}, 'axxb.com'), None, ) check( - _verifycert({'subject': (((u'commonName', u'a*b.co*'),),)}, 'axxb.com'), + _verifycert({'subject': ((('commonName', 'a*b.co*'),),)}, 'axxb.com'), b'certificate is for a*b.co*', ) check( - _verifycert({'subject': (((u'commonName', u'a*b*.com'),),)}, 'axxbxxc.com'), + _verifycert({'subject': ((('commonName', 'a*b*.com'),),)}, 'axxbxxc.com'), b'too many wildcards in certificate DNS name: a*b*.com', )