Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6173285

Browse files
author
Tarek Ziadé
committed
Merged revisions 74501 via svnmerge from
svn+ssh://[email protected]/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 ........
1 parent de55055 commit 6173285

2 files changed

Lines changed: 45 additions & 3 deletions

File tree

Lib/distutils/filelist.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def process_template_line(self, line):
108108
# defined: it's the first word of the line. Which of the other
109109
# three are defined depends on the action; it'll be either
110110
# patterns, (dir and patterns), or (dir_pattern).
111-
(action, patterns, dir, dir_pattern) = self._parse_template_line(line)
111+
action, patterns, dir, dir_pattern = self._parse_template_line(line)
112112

113113
# OK, now we know that the action is valid and we have the
114114
# right number of words on the line for that action -- so we
@@ -175,7 +175,6 @@ def process_template_line(self, line):
175175
raise DistutilsInternalError(
176176
"this cannot happen: invalid action '%s'" % action)
177177

178-
179178
# -- Filtering/selection methods -----------------------------------
180179

181180
def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):

Lib/distutils/tests/test_filelist.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
"""Tests for distutils.filelist."""
2+
from os.path import join
23
import unittest
3-
from distutils.filelist import glob_to_re
4+
from distutils.filelist import glob_to_re, FileList
5+
6+
MANIFEST_IN = """\
7+
include ok
8+
include xo
9+
exclude xo
10+
include foo.tmp
11+
global-include *.x
12+
global-include *.txt
13+
global-exclude *.tmp
14+
recursive-include f *.oo
15+
recursive-exclude global *.x
16+
graft dir
17+
prune dir3
18+
"""
419

520
class FileListTestCase(unittest.TestCase):
621

@@ -16,6 +31,34 @@ def test_glob_to_re(self):
1631
self.assertEquals(glob_to_re('foo????'), r'foo[^/][^/][^/][^/]\Z(?ms)')
1732
self.assertEquals(glob_to_re(r'foo\\??'), r'foo\\\\[^/][^/]\Z(?ms)')
1833

34+
def test_process_template_line(self):
35+
# testing all MANIFEST.in template patterns
36+
file_list = FileList()
37+
38+
# simulated file list
39+
file_list.allfiles = ['foo.tmp', 'ok', 'xo', 'four.txt',
40+
join('global', 'one.txt'),
41+
join('global', 'two.txt'),
42+
join('global', 'files.x'),
43+
join('global', 'here.tmp'),
44+
join('f', 'o', 'f.oo'),
45+
join('dir', 'graft-one'),
46+
join('dir', 'dir2', 'graft2'),
47+
join('dir3', 'ok'),
48+
join('dir3', 'sub', 'ok.txt')
49+
]
50+
51+
for line in MANIFEST_IN.split('\n'):
52+
if line.strip() == '':
53+
continue
54+
file_list.process_template_line(line)
55+
56+
wanted = ['ok', 'four.txt', join('global', 'one.txt'),
57+
join('global', 'two.txt'), join('f', 'o', 'f.oo'),
58+
join('dir', 'graft-one'), join('dir', 'dir2', 'graft2')]
59+
60+
self.assertEquals(file_list.files, wanted)
61+
1962
def test_suite():
2063
return unittest.makeSuite(FileListTestCase)
2164

0 commit comments

Comments
 (0)