summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-02-03 19:59:59 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-02-03 19:59:59 (GMT)
commitd2cc743ca448866197b4ac0bcb918591827f4552 (patch)
tree65eb723dff7cff862368a72fb572e0d62d6c8f58 /Lib/test
parentb3de1a720a7dffcf86bf7e7301263590b5972186 (diff)
downloadcpython-d2cc743ca448866197b4ac0bcb918591827f4552.zip
cpython-d2cc743ca448866197b4ac0bcb918591827f4552.tar.gz
cpython-d2cc743ca448866197b4ac0bcb918591827f4552.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')
-rw-r--r--Lib/test/test_re.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index f093812..1c6f45d 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
@@ -1064,6 +1064,19 @@ 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 '])
+
+
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose: