summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-03-12 23:29:48 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-03-12 23:29:48 (GMT)
commitdf723e1e5e4e0022a28618f953219aaf52852643 (patch)
treeca9573213cd81a4ced57c912c197b4c40c5749e3 /Lib
parent1d4798cb93aabdea7843c85d60b0e898107bae05 (diff)
downloadcpython-df723e1e5e4e0022a28618f953219aaf52852643.zip
cpython-df723e1e5e4e0022a28618f953219aaf52852643.tar.gz
cpython-df723e1e5e4e0022a28618f953219aaf52852643.tar.bz2
#14179: add tests for re.compile. Patch by Florian Mladitsch.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_re.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 4e18531..940ba39 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -818,6 +818,16 @@ class ReTests(unittest.TestCase):
self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow])
self.assertRaises(TypeError, _sre.compile, {}, 0, [])
+ def test_compile(self):
+ # Test return value when given string and pattern as parameter
+ pattern = re.compile('random pattern')
+ self.assertIsInstance(pattern, re._pattern_type)
+ same_pattern = re.compile(pattern)
+ self.assertIsInstance(same_pattern, re._pattern_type)
+ self.assertIs(same_pattern, pattern)
+ # Test behaviour when not given a string or pattern as parameter
+ self.assertRaises(TypeError, re.compile, 0)
+
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose: