mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-33985: Implement ContextVar.name attribute. (GH-7980)
This commit is contained in:
parent
9b9d58f0d8
commit
41cb0baea9
4 changed files with 15 additions and 2 deletions
|
@ -30,8 +30,13 @@ class ContextTest(unittest.TestCase):
|
|||
with self.assertRaisesRegex(TypeError, 'must be a str'):
|
||||
contextvars.ContextVar(1)
|
||||
|
||||
c = contextvars.ContextVar('a')
|
||||
self.assertNotEqual(hash(c), hash('a'))
|
||||
c = contextvars.ContextVar('aaa')
|
||||
self.assertEqual(c.name, 'aaa')
|
||||
|
||||
with self.assertRaises(AttributeError):
|
||||
c.name = 'bbb'
|
||||
|
||||
self.assertNotEqual(hash(c), hash('aaa'))
|
||||
|
||||
def test_context_var_new_2(self):
|
||||
self.assertIsNone(contextvars.ContextVar[int])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue