Issue #19928: Implemented a test for repr() of cell objects.
diff --git a/Lib/test/test_repr.py b/Lib/test/test_repr.py
index 062fccf..ae5203d 100644
--- a/Lib/test/test_repr.py
+++ b/Lib/test/test_repr.py
@@ -179,8 +179,15 @@
self.assertTrue(repr(x).startswith('<read-only buffer for 0x'))
def test_cell(self):
- # XXX Hmm? How to get at a cell object?
- pass
+ def get_cell():
+ x = 42
+ def inner():
+ return x
+ return inner
+ x = get_cell().__closure__[0]
+ self.assertRegexpMatches(repr(x), r'<cell at 0x[0-9a-f]+: '
+ r'int object at 0x[0-9a-f]+>')
+ self.assertRegexpMatches(r(x), r'<cell at.*\.\.\..*>')
def test_descriptors(self):
eq = self.assertEqual