summaryrefslogtreecommitdiff
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-10-25 15:45:42 -0400
committerBrett Cannon <brett@python.org>2013-10-25 15:45:42 -0400
commit502834cf3c6add73507b709b2f65d5118ec3a735 (patch)
tree28c093fd03b976fb1e4b9d4e4f61d6d81bc168ec /Lib/test/test_re.py
parenta20800d1d93bf83c131523f14271a34641f1f588 (diff)
parent3b2f0f045903ba9f24d92c053bd6d0fc8561973f (diff)
downloadcpython-git-502834cf3c6add73507b709b2f65d5118ec3a735.tar.gz
merge
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 5e68585065..9ee077da7b 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -3,10 +3,12 @@ from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G, \
import io
import re
from re import Scanner
+import sre_compile
import sre_constants
import sys
import string
import traceback
+import unittest
from weakref import proxy
# Misc tests from Tim Peters' re.doc
@@ -15,8 +17,6 @@ from weakref import proxy
# what you're doing. Some of these tests were carefully modeled to
# cover most of the code.
-import unittest
-
class S(str):
def __getitem__(self, index):
return S(super().__getitem__(index))
@@ -1140,6 +1140,22 @@ class ReTests(unittest.TestCase):
self.assertEqual(m.group(1), "")
self.assertEqual(m.group(2), "y")
+
+class ImplementationTest(unittest.TestCase):
+ """
+ Test implementation details of the re module.
+ """
+
+ def test_overlap_table(self):
+ f = sre_compile._generate_overlap_table
+ self.assertEqual(f(""), [])
+ self.assertEqual(f("a"), [0])
+ self.assertEqual(f("abcd"), [0, 0, 0, 0])
+ self.assertEqual(f("aaaa"), [0, 1, 2, 3])
+ self.assertEqual(f("ababba"), [0, 0, 1, 2, 0, 1])
+ self.assertEqual(f("abcabdac"), [0, 0, 0, 1, 2, 0, 1, 0])
+
+
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose:
@@ -1269,7 +1285,7 @@ def run_re_tests():
def test_main():
- run_unittest(ReTests)
+ run_unittest(__name__)
run_re_tests()
if __name__ == "__main__":