aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools/tests/test_egg_info.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-12-31 10:51:55 -0500
committerJason R. Coombs <jaraco@jaraco.com>2015-12-31 10:51:55 -0500
commit29fa01621c3de0a5c78c4f49b5d051386d0d566f (patch)
treefce7387c8ba82178be987b004cbda1c22005a04f /setuptools/tests/test_egg_info.py
parent928324bd76f35e9c8c526df828577b5640a95ed0 (diff)
parent6bdbe8957d8c8d293e3fea3fa4baf45eb7c3a3a4 (diff)
downloadexternal_python_setuptools-29fa01621c3de0a5c78c4f49b5d051386d0d566f.tar.gz
external_python_setuptools-29fa01621c3de0a5c78c4f49b5d051386d0d566f.tar.bz2
external_python_setuptools-29fa01621c3de0a5c78c4f49b5d051386d0d566f.zip
Merge with master. Ref #229.
--HG-- branch : feature/issue-229
Diffstat (limited to 'setuptools/tests/test_egg_info.py')
-rw-r--r--setuptools/tests/test_egg_info.py79
1 files changed, 52 insertions, 27 deletions
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py
index a1caf9fd..333d11d6 100644
--- a/setuptools/tests/test_egg_info.py
+++ b/setuptools/tests/test_egg_info.py
@@ -4,11 +4,16 @@ import stat
import pytest
from . import environment
+from .files import build_files
from .textwrap import DALS
from . import contexts
-class TestEggInfo:
+class Environment(str):
+ pass
+
+
+class TestEggInfo(object):
setup_script = DALS("""
from setuptools import setup
@@ -22,19 +27,16 @@ class TestEggInfo:
""")
def _create_project(self):
- with open('setup.py', 'w') as f:
- f.write(self.setup_script)
-
- with open('hello.py', 'w') as f:
- f.write(DALS("""
+ build_files({
+ 'setup.py': self.setup_script,
+ 'hello.py': DALS("""
def run():
print('hello')
- """))
+ """)
+ })
@pytest.yield_fixture
def env(self):
- class Environment(str): pass
-
with contexts.tempdir(prefix='setuptools-test.') as env_dir:
env = Environment(env_dir)
os.chmod(env_dir, stat.S_IRWXU)
@@ -44,18 +46,48 @@ class TestEggInfo:
for dirname in subs
)
list(map(os.mkdir, env.paths.values()))
- config = os.path.join(env.paths['home'], '.pydistutils.cfg')
- with open(config, 'w') as f:
- f.write(DALS("""
+ build_files({
+ env.paths['home']: {
+ '.pydistutils.cfg': DALS("""
[egg_info]
egg-base = %(egg-base)s
- """ % env.paths
- ))
+ """ % env.paths)
+ }
+ })
yield env
def test_egg_base_installed_egg_info(self, tmpdir_cwd, env):
self._create_project()
+ self._run_install_command(tmpdir_cwd, env)
+ actual = self._find_egg_info_files(env.paths['lib'])
+
+ expected = [
+ 'PKG-INFO',
+ 'SOURCES.txt',
+ 'dependency_links.txt',
+ 'entry_points.txt',
+ 'not-zip-safe',
+ 'top_level.txt',
+ ]
+ assert sorted(actual) == expected
+
+ def test_manifest_template_is_read(self, tmpdir_cwd, env):
+ self._create_project()
+ build_files({
+ 'MANIFEST.in': DALS("""
+ recursive-include docs *.rst
+ """),
+ 'docs': {
+ 'usage.rst': "Run 'hi'",
+ }
+ })
+ self._run_install_command(tmpdir_cwd, env)
+ egg_info_dir = self._find_egg_info_files(env.paths['lib']).base
+ sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt')
+ assert 'docs/usage.rst' in open(sources_txt).read().split('\n')
+
+ def _run_install_command(self, tmpdir_cwd, env):
environ = os.environ.copy().update(
HOME=env.paths['home'],
)
@@ -75,21 +107,14 @@ class TestEggInfo:
if code:
raise AssertionError(data)
- actual = self._find_egg_info_files(env.paths['lib'])
-
- expected = [
- 'PKG-INFO',
- 'SOURCES.txt',
- 'dependency_links.txt',
- 'entry_points.txt',
- 'not-zip-safe',
- 'top_level.txt',
- ]
- assert sorted(actual) == expected
-
def _find_egg_info_files(self, root):
+ class DirList(list):
+ def __init__(self, files, base):
+ super(DirList, self).__init__(files)
+ self.base = base
+
results = (
- filenames
+ DirList(filenames, dirpath)
for dirpath, dirnames, filenames in os.walk(root)
if os.path.basename(dirpath) == 'EGG-INFO'
)