diff options
author | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-08-18 08:16:33 +0000 |
---|---|---|
committer | Tarek Ziadé <ziade.tarek@gmail.com> | 2009-08-18 08:16:33 +0000 |
commit | 1c8c9d12642ba04bb22f612f5d09eaf93c274a18 (patch) | |
tree | 5e2d4f3f1bc19269fdf3fd6ae69c5f0a99946bb2 | |
parent | e2f35c3588e6107e0166446c57da1da48399a005 (diff) | |
download | cpython-git-1c8c9d12642ba04bb22f612f5d09eaf93c274a18.tar.gz |
added more test coverage for distutils.filelist to prevent regressions when fnmatch or re are changed
-rw-r--r-- | Lib/distutils/filelist.py | 5 | ||||
-rw-r--r-- | Lib/distutils/tests/test_filelist.py | 45 |
2 files changed, 45 insertions, 5 deletions
diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py index de665e7a8c..7cf05098ed 100644 --- a/Lib/distutils/filelist.py +++ b/Lib/distutils/filelist.py @@ -115,7 +115,7 @@ class FileList: # defined: it's the first word of the line. Which of the other # three are defined depends on the action; it'll be either # patterns, (dir and patterns), or (dir_pattern). - (action, patterns, dir, dir_pattern) = self._parse_template_line(line) + action, patterns, dir, dir_pattern = self._parse_template_line(line) # OK, now we know that the action is valid and we have the # right number of words on the line for that action -- so we @@ -182,9 +182,6 @@ class FileList: raise DistutilsInternalError, \ "this cannot happen: invalid action '%s'" % action - # process_template_line () - - # -- Filtering/selection methods ----------------------------------- def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0): diff --git a/Lib/distutils/tests/test_filelist.py b/Lib/distutils/tests/test_filelist.py index 1faccfae7e..181a58d815 100644 --- a/Lib/distutils/tests/test_filelist.py +++ b/Lib/distutils/tests/test_filelist.py @@ -1,6 +1,21 @@ """Tests for distutils.filelist.""" +from os.path import join import unittest -from distutils.filelist import glob_to_re +from distutils.filelist import glob_to_re, FileList + +MANIFEST_IN = """\ +include ok +include xo +exclude xo +include foo.tmp +global-include *.x +global-include *.txt +global-exclude *.tmp +recursive-include f *.oo +recursive-exclude global *.x +graft dir +prune dir3 +""" class FileListTestCase(unittest.TestCase): @@ -16,6 +31,34 @@ class FileListTestCase(unittest.TestCase): self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)') self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)') + def test_process_template_line(self): + # testing all MANIFEST.in template patterns + file_list = FileList() + + # simulated file list + file_list.allfiles = ['foo.tmp', 'ok', 'xo', 'four.txt' + join('global', 'one.txt'), + join('global', 'two.txt'), + join('global', 'files.x'), + join('global', 'here.tmp'), + join('f', 'o', 'f.oo'), + join('dir', 'graft-one'), + join('dir', 'dir2', 'graft2'), + join('dir3', 'ok'), + join('dir3', 'sub', 'ok.txt') + ] + + for line in MANIFEST_IN.split('\n'): + if line.strip() == '': + continue + file_list.process_template_line(line) + + wanted = ['ok', join('global', 'one.txt'), join('global', 'two.txt'), + 'four.txt', join('f', 'o', 'f.oo'), join('dir', 'graft-one'), + join('dir', 'dir2', 'graft2')] + + self.assertEquals(file_list.files, wanted) + def test_suite(): return unittest.makeSuite(FileListTestCase) |