10000 Issue #19286: Adding test demonstrating the failure when a directory … · python/cpython@93912b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 93912b9

Browse files
committed
Issue #19286: Adding test demonstrating the failure when a directory is found in the package_data globs.
1 parent 35aca89 commit 93912b9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Lib/distutils/tests/test_build_py.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,37 @@ def test_byte_compile_optimized(self):
121121
found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
122122
self.assertEqual(sorted(found), ['boiledeggs.%s.pyo' % imp.get_tag()])
123123

124+
def test_dir_in_package_data(self):
125+
"""
126+
A directory in package_data should not be added to the filelist.
127+
"""
128+
# See bug 19286
129+
sources = self.mkdtemp()
130+
pkg_dir = os.path.join(sources, "pkg")
131+
132+
os.mkdir(pkg_dir)
133+
open(os.path.join(pkg_dir, "__init__.py"), "w").close()
134+
135+
docdir = os.path.join(pkg_dir, "doc")
136+
os.mkdir(docdir)
137+
open(os.path.join(docdir, "testfile"), "w").close()
138+
139+
# create the directory that could be incorrectly detected as a file
140+
os.mkdir(os.path.join(docdir, 'otherdir'))
141+
142+
os.chdir(sources)
143+
dist = Distribution({"packages": ["pkg"],
144+
"package_data": {"pkg": ["doc/*"]}})
145+
# script_name need not exist, it just need to be initialized
146+
dist.script_name = os.path.join(sources, "setup.py")
147+
dist.script_args = ["build"]
148+
dist.parse_command_line()
149+
150+
try:
151+
dist.run_commands()
152+
except DistutilsFileError:
153+
self.fail("failed package_data when data dir includes a dir")
154+
124155
def test_dont_write_bytecode(self):
125156
# makes sure byte_compile is not used
126157
dist = self.create_dist()[1]

0 commit comments

Comments
 (0)
0