summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_context.py
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-10-09 23:37:14 (GMT)
committerGitHub <noreply@github.com>2024-10-09 23:37:14 (GMT)
commit942916378aa6a0946b1385c2c7ca6935620d710a (patch)
treea9fbba1e5c98d5db455c7f0010ee68e44c83172d /Lib/test/test_context.py
parent1b2a5485f94ccbe43a45eb9990a5649ae3d2499e (diff)
downloadcpython-942916378aa6a0946b1385c2c7ca6935620d710a.zip
cpython-942916378aa6a0946b1385c2c7ca6935620d710a.tar.gz
cpython-942916378aa6a0946b1385c2c7ca6935620d710a.tar.bz2
gh-125196: Use PyUnicodeWriter for repr(contextvars.Token) (#125220)
Replace the private _PyUnicodeWriter with the public PyUnicodeWriter.
Diffstat (limited to 'Lib/test/test_context.py')
-rw-r--r--Lib/test/test_context.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_context.py b/Lib/test/test_context.py
index 255be30..b06b9df 100644
--- a/Lib/test/test_context.py
+++ b/Lib/test/test_context.py
@@ -60,6 +60,14 @@ class ContextTest(unittest.TestCase):
c.reset(t)
self.assertIn(' used ', repr(t))
+ @isolated_context
+ def test_token_repr_1(self):
+ c = contextvars.ContextVar('a')
+ tok = c.set(1)
+ self.assertRegex(repr(tok),
+ r"^<Token var=<ContextVar name='a' "
+ r"at 0x[0-9a-fA-F]+> at 0x[0-9a-fA-F]+>$")
+
def test_context_subclassing_1(self):
with self.assertRaisesRegex(TypeError, 'not an acceptable base type'):
class MyContextVar(contextvars.ContextVar):