summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-12-10 08:21:51 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-12-10 08:21:51 (GMT)
commit2a446bf76cd48b0742a5b3958313437fa1243caa (patch)
treedf865e44d48e0dce76a459cc7ec3d1c9ffd7ab7b
parent0ed6c4ae623323a3c491bd2eaaa8956ba2c6b6fa (diff)
parent1f79cdfbfa3f53fb1aa3bb8998c463a5d2614795 (diff)
downloadcpython-2a446bf76cd48b0742a5b3958313437fa1243caa.zip
cpython-2a446bf76cd48b0742a5b3958313437fa1243caa.tar.gz
cpython-2a446bf76cd48b0742a5b3958313437fa1243caa.tar.bz2
Issue #19928: Implemented a test for repr() of cell objects.
-rw-r--r--Lib/test/test_reprlib.py12
-rw-r--r--Misc/NEWS2
2 files changed, 11 insertions, 3 deletions
diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py
index 5b81ce7..9cf54e7 100644
--- a/Lib/test/test_reprlib.py
+++ b/Lib/test/test_reprlib.py
@@ -166,10 +166,16 @@ class ReprTests(unittest.TestCase):
eq(r([[[[[[{}]]]]]]), "[[[[[[{}]]]]]]")
eq(r([[[[[[[{}]]]]]]]), "[[[[[[[...]]]]]]]")
- @unittest.skip('hard to catch a cell object')
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.assertRegex(repr(x),
+ r'<cell at 0x[0-9a-f]+: int object at 0x[0-9a-f]+>')
+ self.assertRegex(r(x), r'<cell at 0x.*\.\.\..*>')
def test_descriptors(self):
eq = self.assertEqual
diff --git a/Misc/NEWS b/Misc/NEWS
index 4190158..5539899 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -136,6 +136,8 @@ IDLE
Tests
-----
+- Issue #19928: Implemented a test for repr() of cell objects.
+
- Issue #19535: Fixed test_docxmlrpc, test_functools, test_inspect, and
test_statistics when python is run with -OO.