]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 74501 via svnmerge from
authorTarek Ziadé <ziade.tarek@gmail.com>
Tue, 18 Aug 2009 08:23:10 +0000 (08:23 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Tue, 18 Aug 2009 08:23:10 +0000 (08:23 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r74501 | tarek.ziade | 2009-08-18 10:16:33 +0200 (Tue, 18 Aug 2009) | 1 line

  added more test coverage for distutils.filelist to prevent regressions when fnmatch or re are changed
........

Lib/distutils/filelist.py
Lib/distutils/tests/test_filelist.py

index b6a1dfeebf96d0251837025a6b0af34eb37fe7a4..bfc6df694a0fdede2bed6871a93e82100f70566c 100644 (file)
@@ -108,7 +108,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
@@ -175,7 +175,6 @@ class FileList:
             raise DistutilsInternalError(
                   "this cannot happen: invalid action '%s'" % action)
 
-
     # -- Filtering/selection methods -----------------------------------
 
     def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
index 1faccfae7e51642da7f23c752b7d26ee46fb41b6..cf64c744d2a971064aef7219b6c66a2eaa072826 100644 (file)
@@ -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', 'four.txt', join('global', 'one.txt'),
+                  join('global', 'two.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)