summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-02-03 20:01:35 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-02-03 20:01:35 (GMT)
commitc49672f25ec86926ed88fd73b3b746674332c797 (patch)
tree5806f2067e8f114a331c88b50f05dd59627a684d /Lib/test/test_re.py
parentb74cf63a0895ff6bd1af82edf623a75e8ea787ee (diff)
parentd2cc743ca448866197b4ac0bcb918591827f4552 (diff)
downloadcpython-c49672f25ec86926ed88fd73b3b746674332c797.zip
cpython-c49672f25ec86926ed88fd73b3b746674332c797.tar.gz
cpython-c49672f25ec86926ed88fd73b3b746674332c797.tar.bz2
Issue #20426: When passing the re.DEBUG flag, re.compile() displays the debug output every time it is called, regardless of the compilation cache.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index a4e11c6..a229e23 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1,5 +1,5 @@
from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G, \
- cpython_only
+ cpython_only, captured_stdout
import io
import re
from re import Scanner
@@ -1193,6 +1193,18 @@ class ReTests(unittest.TestCase):
self.assertEqual(m.group(1), "")
self.assertEqual(m.group(2), "y")
+ def test_debug_flag(self):
+ with captured_stdout() as out:
+ re.compile('foo', re.DEBUG)
+ self.assertEqual(out.getvalue().splitlines(),
+ ['literal 102 ', 'literal 111 ', 'literal 111 '])
+ # Debug output is output again even a second time (bypassing
+ # the cache -- issue #20426).
+ with captured_stdout() as out:
+ re.compile('foo', re.DEBUG)
+ self.assertEqual(out.getvalue().splitlines(),
+ ['literal 102 ', 'literal 111 ', 'literal 111 '])
+
class PatternReprTests(unittest.TestCase):
def check(self, pattern, expected):