Skip to content

Commit

Permalink
In test_build_py, rely on tree builder to build trees. Ref #232.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 2, 2024
1 parent e87efe3 commit 9654a14
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions distutils/tests/test_build_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys

import pytest
import jaraco.path

from distutils.command.build_py import build_py
from distutils.core import Distribution
Expand All @@ -16,16 +17,13 @@
class TestBuildPy(support.TempdirManager):
def test_package_data(self):
sources = self.mkdtemp()
f = open(os.path.join(sources, "__init__.py"), "w")
try:
f.write("# Pretend this is a package.")
finally:
f.close()
f = open(os.path.join(sources, "README.txt"), "w")
try:
f.write("Info about this package")
finally:
f.close()
jaraco.path.build(
{
'__init__.py': "# Pretend this is a package.",
'README.txt': 'Info about this package',
},
sources,
)

destination = self.mkdtemp()

Expand Down Expand Up @@ -62,11 +60,7 @@ def test_package_data(self):
def test_empty_package_dir(self):
# See bugs #1668596/#1720897
sources = self.mkdtemp()
open(os.path.join(sources, "__init__.py"), "w").close()

testdir = os.path.join(sources, "doc")
os.mkdir(testdir)
open(os.path.join(testdir, "testfile"), "w").close()
jaraco.path.build({'__init__.py': '', 'doc': {'testfile': ''}}, sources)

os.chdir(sources)
dist = Distribution({
Expand Down Expand Up @@ -124,17 +118,19 @@ def test_dir_in_package_data(self):
"""
# See bug 19286
sources = self.mkdtemp()
pkg_dir = os.path.join(sources, "pkg")

os.mkdir(pkg_dir)
open(os.path.join(pkg_dir, "__init__.py"), "w").close()

docdir = os.path.join(pkg_dir, "doc")
os.mkdir(docdir)
open(os.path.join(docdir, "testfile"), "w").close()

# create the directory that could be incorrectly detected as a file
os.mkdir(os.path.join(docdir, 'otherdir'))
jaraco.path.build(
{
'pkg': {
'__init__.py': '',
'doc': {
'testfile': '',
# create a directory that could be incorrectly detected as a file
'otherdir': {},
},
}
},
sources,
)

os.chdir(sources)
dist = Distribution({"packages": ["pkg"], "package_data": {"pkg": ["doc/*"]}})
Expand Down Expand Up @@ -174,9 +170,8 @@ def test_namespace_package_does_not_warn(self, caplog):
"""
# Create a fake project structure with a package namespace:
tmp = self.mkdtemp()
jaraco.path.build({'ns': {'pkg': {'module.py': ''}}}, tmp)
os.chdir(tmp)
os.makedirs("ns/pkg")
open("ns/pkg/module.py", "w").close()

# Configure the package:
attrs = {
Expand Down

0 comments on commit 9654a14

Please sign in to comment.