mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Found bug in perlReToPythonRe and fixed it.
This commit is contained in:
parent
167acefe8a
commit
1cd7ccbfa4
@ -227,7 +227,7 @@ def perlReToPythonRe(s):
|
||||
flag = 0
|
||||
try:
|
||||
for c in flags.upper():
|
||||
flag &= getattr(re, c)
|
||||
flag |= getattr(re, c)
|
||||
except AttributeError:
|
||||
raise ValueError, 'Invalid flag: %s' % c
|
||||
return re.compile(regexp, flag)
|
||||
|
@ -113,6 +113,8 @@ class UtilsTest(unittest.TestCase):
|
||||
self.failUnless(r.search('foo'))
|
||||
r = utils.perlReToPythonRe('m/\\//')
|
||||
self.failUnless(r.search('/'))
|
||||
r = utils.perlReToPythonRe('m/cat/i')
|
||||
self.failUnless(r.search('CAT'))
|
||||
|
||||
def testPerlReToReplacer(self):
|
||||
f = utils.perlReToReplacer('s/foo/bar/')
|
||||
@ -127,6 +129,8 @@ class UtilsTest(unittest.TestCase):
|
||||
self.assertEqual(f('foobarbaz'), 'foorz')
|
||||
f = utils.perlReToReplacer('s/ba\\///g')
|
||||
self.assertEqual(f('fooba/rba/z'), 'foorz')
|
||||
f = utils.perlReToReplacer('s/cat/dog/i')
|
||||
self.assertEqual(f('CATFISH'), 'dogFISH')
|
||||
|
||||
def testFindBinaryInPath(self):
|
||||
if os.name == 'posix':
|
||||
|
Loading…
Reference in New Issue
Block a user