mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +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
|
flag = 0
|
||||||
try:
|
try:
|
||||||
for c in flags.upper():
|
for c in flags.upper():
|
||||||
flag &= getattr(re, c)
|
flag |= getattr(re, c)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise ValueError, 'Invalid flag: %s' % c
|
raise ValueError, 'Invalid flag: %s' % c
|
||||||
return re.compile(regexp, flag)
|
return re.compile(regexp, flag)
|
||||||
|
@ -113,6 +113,8 @@ class UtilsTest(unittest.TestCase):
|
|||||||
self.failUnless(r.search('foo'))
|
self.failUnless(r.search('foo'))
|
||||||
r = utils.perlReToPythonRe('m/\\//')
|
r = utils.perlReToPythonRe('m/\\//')
|
||||||
self.failUnless(r.search('/'))
|
self.failUnless(r.search('/'))
|
||||||
|
r = utils.perlReToPythonRe('m/cat/i')
|
||||||
|
self.failUnless(r.search('CAT'))
|
||||||
|
|
||||||
def testPerlReToReplacer(self):
|
def testPerlReToReplacer(self):
|
||||||
f = utils.perlReToReplacer('s/foo/bar/')
|
f = utils.perlReToReplacer('s/foo/bar/')
|
||||||
@ -127,6 +129,8 @@ class UtilsTest(unittest.TestCase):
|
|||||||
self.assertEqual(f('foobarbaz'), 'foorz')
|
self.assertEqual(f('foobarbaz'), 'foorz')
|
||||||
f = utils.perlReToReplacer('s/ba\\///g')
|
f = utils.perlReToReplacer('s/ba\\///g')
|
||||||
self.assertEqual(f('fooba/rba/z'), 'foorz')
|
self.assertEqual(f('fooba/rba/z'), 'foorz')
|
||||||
|
f = utils.perlReToReplacer('s/cat/dog/i')
|
||||||
|
self.assertEqual(f('CATFISH'), 'dogFISH')
|
||||||
|
|
||||||
def testFindBinaryInPath(self):
|
def testFindBinaryInPath(self):
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
|
Loading…
Reference in New Issue
Block a user