summaryrefslogtreecommitdiff
path: root/Lib/test/test_ssl.py
diff options
context:
space:
mode:
authorEthan Furman <ethan@stoneleaf.us>2022-01-15 22:41:43 -0800
committerGitHub <noreply@github.com>2022-01-15 22:41:43 -0800
commitacf7403f9baea3ae1119fc6b4a3298522188bf96 (patch)
treefcffbb83c601353ac1fce9b35b0f2424c8ce9899 /Lib/test/test_ssl.py
parent37eab55ac9da6b6361f136a1da15bfcef12ed954 (diff)
downloadcpython-git-acf7403f9baea3ae1119fc6b4a3298522188bf96.tar.gz
bpo-40066: [Enum] update str() and format() output (GH-30582)
Undo rejected PEP-663 changes: - restore `repr()` to its 3.10 status - restore `str()` to its 3.10 status New changes: - `IntEnum` and `IntFlag` now leave `__str__` as the original `int.__str__` so that str() and format() return the same result - zero-valued flags without a name have a slightly changed repr(), e.g. `repr(Color(0)) == '<Color: 0>'` - update `dir()` for mixed-in types to return all the methods and attributes of the mixed-in type - added `_numeric_repr_` to `Flag` to control display of unnamed values - enums without doc strings have a more comprehensive doc string added - `ReprEnum` added -- inheriting from this makes it so only `__repr__` is replaced, not `__str__` nor `__format__`; `IntEnum`, `IntFlag`, and `StrEnum` all inherit from `ReprEnum`
Diffstat (limited to 'Lib/test/test_ssl.py')
-rw-r--r--Lib/test/test_ssl.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index f99a3e8da9..64f4bce7f7 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -373,7 +373,8 @@ class BasicSocketTests(unittest.TestCase):
# Make sure that the PROTOCOL_* constants have enum-like string
# reprs.
proto = ssl.PROTOCOL_TLS_CLIENT
- self.assertEqual(str(proto), 'PROTOCOL_TLS_CLIENT')
+ self.assertEqual(repr(proto), '<_SSLMethod.PROTOCOL_TLS_CLIENT: 16>')
+ self.assertEqual(str(proto), '16')
ctx = ssl.SSLContext(proto)
self.assertIs(ctx.protocol, proto)
@@ -622,7 +623,7 @@ class BasicSocketTests(unittest.TestCase):
with self.assertWarns(DeprecationWarning) as cm:
ssl.SSLContext(protocol)
self.assertEqual(
- f'{protocol!r} is deprecated',
+ f'ssl.{protocol.name} is deprecated',
str(cm.warning)
)
@@ -631,8 +632,9 @@ class BasicSocketTests(unittest.TestCase):
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
with self.assertWarns(DeprecationWarning) as cm:
ctx.minimum_version = version
+ version_text = '%s.%s' % (version.__class__.__name__, version.name)
self.assertEqual(
- f'ssl.{version!r} is deprecated',
+ f'ssl.{version_text} is deprecated',
str(cm.warning)
)