diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-14 13:20:20 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-09-14 13:20:20 (GMT) |
commit | d9cf65f00ec41c251296ae56737a541c68b60510 (patch) | |
tree | 8ab21966dc724f7965a5cd4b3493fd6564a21918 /Lib/test/test_re.py | |
parent | a25875cfd0c36f5893d8e86bcfa4dea341c4c817 (diff) | |
download | cpython-d9cf65f00ec41c251296ae56737a541c68b60510.zip cpython-d9cf65f00ec41c251296ae56737a541c68b60510.tar.gz cpython-d9cf65f00ec41c251296ae56737a541c68b60510.tar.bz2 |
Use more appropriate asserts in re tests.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r-- | Lib/test/test_re.py | 230 |
1 files changed, 115 insertions, 115 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index b426f9f..c650f7a 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -59,12 +59,12 @@ class ReTests(unittest.TestCase): self.assertEqual(re.search('x*', 'axx').span(), (0, 0)) self.assertEqual(re.search('x+', 'axx').span(0), (1, 3)) self.assertEqual(re.search('x+', 'axx').span(), (1, 3)) - self.assertEqual(re.search('x', 'aaa'), None) + self.assertIsNone(re.search('x', 'aaa')) self.assertEqual(re.match('a*', 'xxx').span(0), (0, 0)) self.assertEqual(re.match('a*', 'xxx').span(), (0, 0)) self.assertEqual(re.match('x*', 'xxxa').span(0), (0, 3)) self.assertEqual(re.match('x*', 'xxxa').span(), (0, 3)) - self.assertEqual(re.match('a+', 'xxx'), None) + self.assertIsNone(re.match('a+', 'xxx')) def bump_num(self, matchobj): int_value = int(matchobj.group(0)) @@ -384,8 +384,8 @@ class ReTests(unittest.TestCase): ('(', 'a')) self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', 'a').groups(), (None, 'a')) - self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', 'a)'), None) - self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a'), None) + self.assertIsNone(re.match('^(\()?([^()]+)(?(1)\))$', 'a)')) + self.assertIsNone(re.match('^(\()?([^()]+)(?(1)\))$', '(a')) self.assertEqual(re.match('^(?:(a)|c)((?(1)b|d))$', 'ab').groups(), ('a', 'b')) self.assertEqual(re.match('^(?:(a)|c)((?(1)b|d))$', 'cd').groups(), @@ -401,8 +401,8 @@ class ReTests(unittest.TestCase): ('a', 'b', 'c')) self.assertEqual(p.match('ad').groups(), ('a', None, 'd')) - self.assertEqual(p.match('abd'), None) - self.assertEqual(p.match('ac'), None) + self.assertIsNone(p.match('abd')) + self.assertIsNone(p.match('ac')) def test_re_groupref(self): @@ -410,8 +410,8 @@ class ReTests(unittest.TestCase): ('|', 'a')) self.assertEqual(re.match(r'^(\|)?([^()]+)\1?$', 'a').groups(), (None, 'a')) - self.assertEqual(re.match(r'^(\|)?([^()]+)\1$', 'a|'), None) - self.assertEqual(re.match(r'^(\|)?([^()]+)\1$', '|a'), None) + self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', 'a|')) + self.assertIsNone(re.match(r'^(\|)?([^()]+)\1$', '|a')) self.assertEqual(re.match(r'^(?:(a)|c)(\1)$', 'aa').groups(), ('a', 'a')) self.assertEqual(re.match(r'^(?:(a)|c)(\1)?$', 'c').groups(), @@ -429,10 +429,10 @@ class ReTests(unittest.TestCase): "second first second first") def test_repeat_minmax(self): - self.assertEqual(re.match("^(\w){1}$", "abc"), None) - self.assertEqual(re.match("^(\w){1}?$", "abc"), None) - self.assertEqual(re.match("^(\w){1,2}$", "abc"), None) - self.assertEqual(re.match("^(\w){1,2}?$", "abc"), None) + self.assertIsNone(re.match("^(\w){1}$", "abc")) + self.assertIsNone(re.match("^(\w){1}?$", "abc")) + self.assertIsNone(re.match("^(\w){1,2}$", "abc")) + self.assertIsNone(re.match("^(\w){1,2}?$", "abc")) self.assertEqual(re.match("^(\w){3}$", "abc").group(1), "c") self.assertEqual(re.match("^(\w){1,3}$", "abc").group(1), "c") @@ -443,22 +443,22 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match("^(\w){1,4}?$", "abc").group(1), "c") self.assertEqual(re.match("^(\w){3,4}?$", "abc").group(1), "c") - self.assertEqual(re.match("^x{1}$", "xxx"), None) - self.assertEqual(re.match("^x{1}?$", "xxx"), None) - self.assertEqual(re.match("^x{1,2}$", "xxx"), None) - self.assertEqual(re.match("^x{1,2}?$", "xxx"), None) + self.assertIsNone(re.match("^x{1}$", "xxx")) + self.assertIsNone(re.match("^x{1}?$", "xxx")) + self.assertIsNone(re.match("^x{1,2}$", "xxx")) + self.assertIsNone(re.match("^x{1,2}?$", "xxx")) - self.assertNotEqual(re.match("^x{3}$", "xxx"), None) - self.assertNotEqual(re.match("^x{1,3}$", "xxx"), None) - self.assertNotEqual(re.match("^x{1,4}$", "xxx"), None) - self.assertNotEqual(re.match("^x{3,4}?$", "xxx"), None) - self.assertNotEqual(re.match("^x{3}?$", "xxx"), None) - self.assertNotEqual(re.match("^x{1,3}?$", "xxx"), None) - self.assertNotEqual(re.match("^x{1,4}?$", "xxx"), None) - self.assertNotEqual(re.match("^x{3,4}?$", "xxx"), None) + self.assertTrue(re.match("^x{3}$", "xxx")) + self.assertTrue(re.match("^x{1,3}$", "xxx")) + self.assertTrue(re.match("^x{1,4}$", "xxx")) + self.assertTrue(re.match("^x{3,4}?$", "xxx")) + self.assertTrue(re.match("^x{3}?$", "xxx")) + self.assertTrue(re.match("^x{1,3}?$", "xxx")) + self.assertTrue(re.match("^x{1,4}?$", "xxx")) + self.assertTrue(re.match("^x{3,4}?$", "xxx")) - self.assertEqual(re.match("^x{}$", "xxx"), None) - self.assertNotEqual(re.match("^x{}$", "x{}"), None) + self.assertIsNone(re.match("^x{}$", "xxx")) + self.assertTrue(re.match("^x{}$", "x{}")) def test_getattr(self): self.assertEqual(re.compile("(?i)(a)(b)").pattern, "(?i)(a)(b)") @@ -472,7 +472,7 @@ class ReTests(unittest.TestCase): self.assertEqual(re.match("(a)", "a").endpos, 1) self.assertEqual(re.match("(a)", "a").string, "a") self.assertEqual(re.match("(a)", "a").regs, ((0, 1), (0, 1))) - self.assertNotEqual(re.match("(a)", "a").re, None) + self.assertTrue(re.match("(a)", "a").re) def test_special_escapes(self): self.assertEqual(re.search(r"\b(b.)\b", @@ -489,7 +489,7 @@ class ReTests(unittest.TestCase): "abc bcd bc abxd", re.LOCALE).group(1), "bx") self.assertEqual(re.search(r"^abc$", "\nabc\n", re.M).group(0), "abc") self.assertEqual(re.search(r"^\Aabc\Z$", "abc", re.M).group(0), "abc") - self.assertEqual(re.search(r"^\Aabc\Z$", "\nabc\n", re.M), None) + self.assertIsNone(re.search(r"^\Aabc\Z$", "\nabc\n", re.M)) self.assertEqual(re.search(br"\b(b.)\b", b"abcd abc bcd bx").group(1), b"bx") self.assertEqual(re.search(br"\B(b.)\B", @@ -500,7 +500,7 @@ class ReTests(unittest.TestCase): b"abc bcd bc abxd", re.LOCALE).group(1), b"bx") self.assertEqual(re.search(br"^abc$", b"\nabc\n", re.M).group(0), b"abc") self.assertEqual(re.search(br"^\Aabc\Z$", b"abc", re.M).group(0), b"abc") - self.assertEqual(re.search(br"^\Aabc\Z$", b"\nabc\n", re.M), None) + self.assertIsNone(re.search(br"^\Aabc\Z$", b"\nabc\n", re.M)) self.assertEqual(re.search(r"\d\D\w\W\s\S", "1aa! a").group(0), "1aa! a") self.assertEqual(re.search(br"\d\D\w\W\s\S", @@ -524,10 +524,10 @@ class ReTests(unittest.TestCase): self.assertFalse(re.match(r"\B", "abc")) # However, an empty string contains no word boundaries, and also no # non-boundaries. - self.assertEqual(re.search(r"\B", ""), None) + self.assertIsNone(re.search(r"\B", "")) # This one is questionable and different from the perlre behaviour, # but describes current behavior. - self.assertEqual(re.search(r"\b", ""), None) + self.assertIsNone(re.search(r"\b", "")) # A single word-character string has two boundaries, but no # non-boundary gaps. self.assertEqual(len(re.findall(r"\b", "a")), 2) @@ -547,8 +547,8 @@ class ReTests(unittest.TestCase): def test_big_codesize(self): # Issue #1160 r = re.compile('|'.join(('%d'%x for x in range(10000)))) - self.assertIsNotNone(r.match('1000')) - self.assertIsNotNone(r.match('9999')) + self.assertTrue(r.match('1000')) + self.assertTrue(r.match('9999')) def test_anyall(self): self.assertEqual(re.match("a.b", "a\nb", re.DOTALL).group(0), @@ -674,29 +674,29 @@ class ReTests(unittest.TestCase): def test_flags(self): for flag in [re.I, re.M, re.X, re.S, re.L]: - self.assertNotEqual(re.compile('^pattern$', flag), None) + self.assertTrue(re.compile('^pattern$', flag)) def test_sre_character_literals(self): for i in [0, 8, 16, 32, 64, 127, 128, 255, 256, 0xFFFF, 0x10000, 0x10FFFF]: if i < 256: - self.assertIsNotNone(re.match(r"\%03o" % i, chr(i))) - self.assertIsNotNone(re.match(r"\%03o0" % i, chr(i)+"0")) - self.assertIsNotNone(re.match(r"\%03o8" % i, chr(i)+"8")) - self.assertIsNotNone(re.match(r"\x%02x" % i, chr(i))) - self.assertIsNotNone(re.match(r"\x%02x0" % i, chr(i)+"0")) - self.assertIsNotNone(re.match(r"\x%02xz" % i, chr(i)+"z")) + self.assertTrue(re.match(r"\%03o" % i, chr(i))) + self.assertTrue(re.match(r"\%03o0" % i, chr(i)+"0")) + self.assertTrue(re.match(r"\%03o8" % i, chr(i)+"8")) + self.assertTrue(re.match(r"\x%02x" % i, chr(i))) + self.assertTrue(re.match(r"\x%02x0" % i, chr(i)+"0")) + self.assertTrue(re.match(r"\x%02xz" % i, chr(i)+"z")) if i < 0x10000: - self.assertIsNotNone(re.match(r"\u%04x" % i, chr(i))) - self.assertIsNotNone(re.match(r"\u%04x0" % i, chr(i)+"0")) - self.assertIsNotNone(re.match(r"\u%04xz" % i, chr(i)+"z")) - self.assertIsNotNone(re.match(r"\U%08x" % i, chr(i))) - self.assertIsNotNone(re.match(r"\U%08x0" % i, chr(i)+"0")) - self.assertIsNotNone(re.match(r"\U%08xz" % i, chr(i)+"z")) - self.assertIsNotNone(re.match(r"\0", "\000")) - self.assertIsNotNone(re.match(r"\08", "\0008")) - self.assertIsNotNone(re.match(r"\01", "\001")) - self.assertIsNotNone(re.match(r"\018", "\0018")) - self.assertIsNotNone(re.match(r"\567", chr(0o167))) + self.assertTrue(re.match(r"\u%04x" % i, chr(i))) + self.assertTrue(re.match(r"\u%04x0" % i, chr(i)+"0")) + self.assertTrue(re.match(r"\u%04xz" % i, chr(i)+"z")) + self.assertTrue(re.match(r"\U%08x" % i, chr(i))) + self.assertTrue(re.match(r"\U%08x0" % i, chr(i)+"0")) + self.assertTrue(re.match(r"\U%08xz" % i, chr(i)+"z")) + self.assertTrue(re.match(r"\0", "\000")) + self.assertTrue(re.match(r"\08", "\0008")) + self.assertTrue(re.match(r"\01", "\001")) + self.assertTrue(re.match(r"\018", "\0018")) + self.assertTrue(re.match(r"\567", chr(0o167))) self.assertRaises(re.error, re.match, r"\911", "") self.assertRaises(re.error, re.match, r"\x1", "") self.assertRaises(re.error, re.match, r"\x1z", "") @@ -709,22 +709,22 @@ class ReTests(unittest.TestCase): def test_sre_character_class_literals(self): for i in [0, 8, 16, 32, 64, 127, 128, 255, 256, 0xFFFF, 0x10000, 0x10FFFF]: if i < 256: - self.assertIsNotNone(re.match(r"[\%o]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\%o8]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\%03o]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\%03o0]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\%03o8]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\x%02x]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\x%02x0]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\x%02xz]" % i, chr(i))) + self.assertTrue(re.match(r"[\%o]" % i, chr(i))) + self.assertTrue(re.match(r"[\%o8]" % i, chr(i))) + self.assertTrue(re.match(r"[\%03o]" % i, chr(i))) + self.assertTrue(re.match(r"[\%03o0]" % i, chr(i))) + self.assertTrue(re.match(r"[\%03o8]" % i, chr(i))) + self.assertTrue(re.match(r"[\x%02x]" % i, chr(i))) + self.assertTrue(re.match(r"[\x%02x0]" % i, chr(i))) + self.assertTrue(re.match(r"[\x%02xz]" % i, chr(i))) if i < 0x10000: - self.assertIsNotNone(re.match(r"[\u%04x]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\u%04x0]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\u%04xz]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\U%08x]" % i, chr(i))) - self.assertIsNotNone(re.match(r"[\U%08x0]" % i, chr(i)+"0")) - self.assertIsNotNone(re.match(r"[\U%08xz]" % i, chr(i)+"z")) - self.assertIsNotNone(re.match(r"[\U0001d49c-\U0001d4b5]", "\U0001d49e")) + self.assertTrue(re.match(r"[\u%04x]" % i, chr(i))) + self.assertTrue(re.match(r"[\u%04x0]" % i, chr(i))) + self.assertTrue(re.match(r"[\u%04xz]" % i, chr(i))) + self.assertTrue(re.match(r"[\U%08x]" % i, chr(i))) + self.assertTrue(re.match(r"[\U%08x0]" % i, chr(i)+"0")) + self.assertTrue(re.match(r"[\U%08xz]" % i, chr(i)+"z")) + self.assertTrue(re.match(r"[\U0001d49c-\U0001d4b5]", "\U0001d49e")) self.assertRaises(re.error, re.match, r"[\911]", "") self.assertRaises(re.error, re.match, r"[\x1z]", "") self.assertRaises(re.error, re.match, r"[\u123z]", "") @@ -733,35 +733,35 @@ class ReTests(unittest.TestCase): def test_sre_byte_literals(self): for i in [0, 8, 16, 32, 64, 127, 128, 255]: - self.assertIsNotNone(re.match((r"\%03o" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"\%03o0" % i).encode(), bytes([i])+b"0")) - self.assertIsNotNone(re.match((r"\%03o8" % i).encode(), bytes([i])+b"8")) - self.assertIsNotNone(re.match((r"\x%02x" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"\x%02x0" % i).encode(), bytes([i])+b"0")) - self.assertIsNotNone(re.match((r"\x%02xz" % i).encode(), bytes([i])+b"z")) - self.assertIsNotNone(re.match(br"\u", b'u')) - self.assertIsNotNone(re.match(br"\U", b'U')) - self.assertIsNotNone(re.match(br"\0", b"\000")) - self.assertIsNotNone(re.match(br"\08", b"\0008")) - self.assertIsNotNone(re.match(br"\01", b"\001")) - self.assertIsNotNone(re.match(br"\018", b"\0018")) - self.assertIsNotNone(re.match(br"\567", bytes([0o167]))) + self.assertTrue(re.match((r"\%03o" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"\%03o0" % i).encode(), bytes([i])+b"0")) + self.assertTrue(re.match((r"\%03o8" % i).encode(), bytes([i])+b"8")) + self.assertTrue(re.match((r"\x%02x" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"\x%02x0" % i).encode(), bytes([i])+b"0")) + self.assertTrue(re.match((r"\x%02xz" % i).encode(), bytes([i])+b"z")) + self.assertTrue(re.match(br"\u", b'u')) + self.assertTrue(re.match(br"\U", b'U')) + self.assertTrue(re.match(br"\0", b"\000")) + self.assertTrue(re.match(br"\08", b"\0008")) + self.assertTrue(re.match(br"\01", b"\001")) + self.assertTrue(re.match(br"\018", b"\0018")) + self.assertTrue(re.match(br"\567", bytes([0o167]))) self.assertRaises(re.error, re.match, br"\911", b"") self.assertRaises(re.error, re.match, br"\x1", b"") self.assertRaises(re.error, re.match, br"\x1z", b"") def test_sre_byte_class_literals(self): for i in [0, 8, 16, 32, 64, 127, 128, 255]: - self.assertIsNotNone(re.match((r"[\%o]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\%o8]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\%03o]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\%03o0]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\%03o8]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\x%02x]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\x%02x0]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match((r"[\x%02xz]" % i).encode(), bytes([i]))) - self.assertIsNotNone(re.match(br"[\u]", b'u')) - self.assertIsNotNone(re.match(br"[\U]", b'U')) + self.assertTrue(re.match((r"[\%o]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\%o8]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\%03o]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\%03o0]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\%03o8]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\x%02x]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\x%02x0]" % i).encode(), bytes([i]))) + self.assertTrue(re.match((r"[\x%02xz]" % i).encode(), bytes([i]))) + self.assertTrue(re.match(br"[\u]", b'u')) + self.assertTrue(re.match(br"[\U]", b'U')) self.assertRaises(re.error, re.match, br"[\911]", "") self.assertRaises(re.error, re.match, br"[\x1z]", "") @@ -772,7 +772,7 @@ class ReTests(unittest.TestCase): def test_bug_527371(self): # bug described in patches 527371/672491 - self.assertEqual(re.match(r'(a)?a','a').lastindex, None) + self.assertIsNone(re.match(r'(a)?a','a').lastindex) self.assertEqual(re.match(r'(a)(b)?b','ab').lastindex, 1) self.assertEqual(re.match(r'(?P<a>a)(?P<b>b)?b','ab').lastgroup, 'a') self.assertEqual(re.match("(?P<a>a(b))", "ab").lastgroup, 'a') @@ -829,7 +829,7 @@ class ReTests(unittest.TestCase): (r"\s+", None), ]) - self.assertNotEqual(scanner.scanner.scanner("").pattern, None) + self.assertTrue(scanner.scanner.scanner("").pattern) self.assertEqual(scanner.scan("sum = 3*foo + 312.50 + bar"), (['sum', 'op=', 3, 'op*', 'foo', 'op+', 312.5, @@ -874,7 +874,7 @@ class ReTests(unittest.TestCase): # bug 764548, re.compile() barfs on str/unicode subclasses class my_unicode(str): pass pat = re.compile(my_unicode("abc")) - self.assertEqual(pat.match("xyz"), None) + self.assertIsNone(pat.match("xyz")) def test_finditer(self): iter = re.finditer(r":+", "a:b::c:::d") @@ -902,8 +902,8 @@ class ReTests(unittest.TestCase): ["::", "::"]) def test_bug_926075(self): - self.assertTrue(re.compile('bug_926075') is not - re.compile(b'bug_926075')) + self.assertIsNot(re.compile('bug_926075'), + re.compile(b'bug_926075')) def test_bug_931848(self): pattern = "[\u002E\u3002\uFF0E\uFF61]" @@ -917,7 +917,7 @@ class ReTests(unittest.TestCase): scanner = re.compile(r"\s").scanner("a b") self.assertEqual(scanner.search().span(), (1, 2)) - self.assertEqual(scanner.search(), None) + self.assertIsNone(scanner.search()) def test_bug_817234(self): iter = re.finditer(r".*", "asdf") @@ -951,7 +951,7 @@ class ReTests(unittest.TestCase): import array for typecode in 'bBuhHiIlLfd': a = array.array(typecode) - self.assertEqual(re.compile(b"bla").match(a), None) + self.assertIsNone(re.compile(b"bla").match(a)) self.assertEqual(re.compile(b"").match(a).groups(), ()) def test_inline_flags(self): @@ -961,27 +961,27 @@ class ReTests(unittest.TestCase): p = re.compile(upper_char, re.I | re.U) q = p.match(lower_char) - self.assertNotEqual(q, None) + self.assertTrue(q) p = re.compile(lower_char, re.I | re.U) q = p.match(upper_char) - self.assertNotEqual(q, None) + self.assertTrue(q) p = re.compile('(?i)' + upper_char, re.U) q = p.match(lower_char) - self.assertNotEqual(q, None) + self.assertTrue(q) p = re.compile('(?i)' + lower_char, re.U) q = p.match(upper_char) - self.assertNotEqual(q, None) + self.assertTrue(q) p = re.compile('(?iu)' + upper_char) q = p.match(lower_char) - self.assertNotEqual(q, None) + self.assertTrue(q) p = re.compile('(?iu)' + lower_char) q = p.match(upper_char) - self.assertNotEqual(q, None) + self.assertTrue(q) def test_dollar_matches_twice(self): "$ matches the end of string, and just before the terminating \n" @@ -1012,23 +1012,23 @@ class ReTests(unittest.TestCase): # String patterns for flags in (0, re.UNICODE): pat = re.compile('\xc0', flags | re.IGNORECASE) - self.assertNotEqual(pat.match('\xe0'), None) + self.assertTrue(pat.match('\xe0')) pat = re.compile('\w', flags) - self.assertNotEqual(pat.match('\xe0'), None) + self.assertTrue(pat.match('\xe0')) pat = re.compile('\xc0', re.ASCII | re.IGNORECASE) - self.assertEqual(pat.match('\xe0'), None) + self.assertIsNone(pat.match('\xe0')) pat = re.compile('(?a)\xc0', re.IGNORECASE) - self.assertEqual(pat.match('\xe0'), None) + self.assertIsNone(pat.match('\xe0')) pat = re.compile('\w', re.ASCII) - self.assertEqual(pat.match('\xe0'), None) + self.assertIsNone(pat.match('\xe0')) pat = re.compile('(?a)\w') - self.assertEqual(pat.match('\xe0'), None) + self.assertIsNone(pat.match('\xe0')) # Bytes patterns for flags in (0, re.ASCII): pat = re.compile(b'\xc0', flags | re.IGNORECASE) - self.assertEqual(pat.match(b'\xe0'), None) + self.assertIsNone(pat.match(b'\xe0')) pat = re.compile(b'\w', flags) - self.assertEqual(pat.match(b'\xe0'), None) + self.assertIsNone(pat.match(b'\xe0')) # Incompatibilities self.assertRaises(ValueError, re.compile, b'\w', re.UNICODE) self.assertRaises(ValueError, re.compile, b'(?u)\w') @@ -1068,11 +1068,11 @@ class ReTests(unittest.TestCase): self.assertRaises(TypeError, _sre.compile, {}, 0, []) def test_search_dot_unicode(self): - self.assertIsNotNone(re.search("123.*-", '123abc-')) - self.assertIsNotNone(re.search("123.*-", '123\xe9-')) - self.assertIsNotNone(re.search("123.*-", '123\u20ac-')) - self.assertIsNotNone(re.search("123.*-", '123\U0010ffff-')) - self.assertIsNotNone(re.search("123.*-", '123\xe9\u20ac\U0010ffff-')) + self.assertTrue(re.search("123.*-", '123abc-')) + self.assertTrue(re.search("123.*-", '123\xe9-')) + self.assertTrue(re.search("123.*-", '123\u20ac-')) + self.assertTrue(re.search("123.*-", '123\U0010ffff-')) + self.assertTrue(re.search("123.*-", '123\xe9\u20ac\U0010ffff-')) def test_compile(self): # Test return value when given string and pattern as parameter |