From df723e1e5e4e0022a28618f953219aaf52852643 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Tue, 13 Mar 2012 01:29:48 +0200 Subject: #14179: add tests for re.compile. Patch by Florian Mladitsch. --- Lib/test/test_re.py | 10 ++++++++++ Misc/ACKS | 1 + 2 files changed, 11 insertions(+) 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: diff --git a/Misc/ACKS b/Misc/ACKS index e7bc2b6..a7d89d3 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -629,6 +629,7 @@ Roman Milner Andrii V. Mishkovskyi Dustin J. Mitchell Dom Mitchell +Florian Mladitsch Doug Moen The Dragon De Monsyne Skip Montanaro -- cgit v0.12