reapplied r74493 (after #6665 fix has been backported)

This commit is contained in:
Tarek Ziadé 2009-11-01 23:11:55 +00:00
parent ec416617e8
commit 628b41f2bd
3 changed files with 12 additions and 9 deletions

View File

@ -312,7 +312,9 @@ def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
pattern_re = '' pattern_re = ''
if prefix is not None: if prefix is not None:
prefix_re = (glob_to_re(prefix))[0:-1] # ditch trailing $ # ditch end of pattern character
empty_pattern = glob_to_re('')
prefix_re = (glob_to_re(prefix))[:-len(empty_pattern)]
pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re) pattern_re = "^" + os.path.join(prefix_re, ".*" + pattern_re)
else: # no prefix -- respect anchor flag else: # no prefix -- respect anchor flag
if anchor: if anchor:

View File

@ -69,6 +69,7 @@ class BuildPyTestCase(support.TempdirManager,
open(os.path.join(testdir, "testfile"), "w").close() open(os.path.join(testdir, "testfile"), "w").close()
os.chdir(sources) os.chdir(sources)
old_stdout = sys.stdout
sys.stdout = io.StringIO() sys.stdout = io.StringIO()
try: try:
@ -87,7 +88,7 @@ class BuildPyTestCase(support.TempdirManager,
finally: finally:
# Restore state. # Restore state.
os.chdir(cwd) os.chdir(cwd)
sys.stdout = sys.__stdout__ sys.stdout = old_stdout
def test_dont_write_bytecode(self): def test_dont_write_bytecode(self):
# makes sure byte_compile is not used # makes sure byte_compile is not used

View File

@ -9,15 +9,15 @@ class FileListTestCase(unittest.TestCase):
def test_glob_to_re(self): def test_glob_to_re(self):
# simple cases # simple cases
self.assertEquals(glob_to_re('foo*'), 'foo[^/]*$') self.assertEquals(glob_to_re('foo*'), 'foo[^/]*\\Z(?ms)')
self.assertEquals(glob_to_re('foo?'), 'foo[^/]$') self.assertEquals(glob_to_re('foo?'), 'foo[^/]\\Z(?ms)')
self.assertEquals(glob_to_re('foo??'), 'foo[^/][^/]$') self.assertEquals(glob_to_re('foo??'), 'foo[^/][^/]\\Z(?ms)')
# special cases # special cases
self.assertEquals(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*$') self.assertEquals(glob_to_re(r'foo\\*'), r'foo\\\\[^/]*\Z(?ms)')
self.assertEquals(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*$') self.assertEquals(glob_to_re(r'foo\\\*'), r'foo\\\\\\[^/]*\Z(?ms)')
self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]$') self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)')
self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]$') self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)')
def test_debug_print(self): def test_debug_print(self):
file_list = FileList() file_list = FileList()