Commit c608faf8 authored by Jason R. Coombs's avatar Jason R. Coombs

Tests in test_egg_info no longer invoke 'setup.py install', but instead focus...

Tests in test_egg_info no longer invoke 'setup.py install', but instead focus on the behavior in egg_info as the namesake suggests.
parent af30e013
...@@ -128,11 +128,11 @@ class TestEggInfo(object): ...@@ -128,11 +128,11 @@ class TestEggInfo(object):
self._validate_content_order(content, expected_order) self._validate_content_order(content, expected_order)
def test_egg_base_installed_egg_info(self, tmpdir_cwd, env): def test_expected_files_produced(self, tmpdir_cwd, env):
self._create_project() self._create_project()
self._run_install_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
actual = self._find_egg_info_files(env.paths['lib']) actual = os.listdir('foo.egg-info')
expected = [ expected = [
'PKG-INFO', 'PKG-INFO',
...@@ -154,8 +154,8 @@ class TestEggInfo(object): ...@@ -154,8 +154,8 @@ class TestEggInfo(object):
'usage.rst': "Run 'hi'", 'usage.rst': "Run 'hi'",
} }
}) })
self._run_install_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
egg_info_dir = self._find_egg_info_files(env.paths['lib']).base egg_info_dir = os.path.join('.', 'foo.egg-info')
sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt') sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt')
with open(sources_txt) as f: with open(sources_txt) as f:
assert 'docs/usage.rst' in f.read().split('\n') assert 'docs/usage.rst' in f.read().split('\n')
...@@ -394,7 +394,7 @@ class TestEggInfo(object): ...@@ -394,7 +394,7 @@ class TestEggInfo(object):
self, tmpdir_cwd, env, requires, use_setup_cfg, self, tmpdir_cwd, env, requires, use_setup_cfg,
expected_requires, install_cmd_kwargs): expected_requires, install_cmd_kwargs):
self._setup_script_with_requires(requires, use_setup_cfg) self._setup_script_with_requires(requires, use_setup_cfg)
self._run_install_command(tmpdir_cwd, env, **install_cmd_kwargs) self._run_egg_info_command(tmpdir_cwd, env, **install_cmd_kwargs)
egg_info_dir = os.path.join('.', 'foo.egg-info') egg_info_dir = os.path.join('.', 'foo.egg-info')
requires_txt = os.path.join(egg_info_dir, 'requires.txt') requires_txt = os.path.join(egg_info_dir, 'requires.txt')
if os.path.exists(requires_txt): if os.path.exists(requires_txt):
...@@ -414,14 +414,14 @@ class TestEggInfo(object): ...@@ -414,14 +414,14 @@ class TestEggInfo(object):
req = 'install_requires={"fake-factory==0.5.2", "pytz"}' req = 'install_requires={"fake-factory==0.5.2", "pytz"}'
self._setup_script_with_requires(req) self._setup_script_with_requires(req)
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
self._run_install_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
def test_extras_require_with_invalid_marker(self, tmpdir_cwd, env): def test_extras_require_with_invalid_marker(self, tmpdir_cwd, env):
tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},' tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},'
req = tmpl.format(marker=self.invalid_marker) req = tmpl.format(marker=self.invalid_marker)
self._setup_script_with_requires(req) self._setup_script_with_requires(req)
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
self._run_install_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env): def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env):
...@@ -429,7 +429,7 @@ class TestEggInfo(object): ...@@ -429,7 +429,7 @@ class TestEggInfo(object):
req = tmpl.format(marker=self.invalid_marker) req = tmpl.format(marker=self.invalid_marker)
self._setup_script_with_requires(req) self._setup_script_with_requires(req)
with pytest.raises(AssertionError): with pytest.raises(AssertionError):
self._run_install_command(tmpdir_cwd, env) self._run_egg_info_command(tmpdir_cwd, env)
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == [] assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
def test_provides_extra(self, tmpdir_cwd, env): def test_provides_extra(self, tmpdir_cwd, env):
...@@ -541,15 +541,6 @@ class TestEggInfo(object): ...@@ -541,15 +541,6 @@ class TestEggInfo(object):
assert 'Requires-Python: >=2.7.12' in pkg_info_lines assert 'Requires-Python: >=2.7.12' in pkg_info_lines
assert 'Metadata-Version: 1.2' in pkg_info_lines assert 'Metadata-Version: 1.2' in pkg_info_lines
def test_python_requires_install(self, tmpdir_cwd, env):
self._setup_script_with_requires(
"""python_requires='>=1.2.3',""")
self._run_install_command(tmpdir_cwd, env)
egg_info_dir = self._find_egg_info_files(env.paths['lib']).base
pkginfo = os.path.join(egg_info_dir, 'PKG-INFO')
with open(pkginfo) as f:
assert 'Requires-Python: >=1.2.3' in f.read().split('\n')
def test_manifest_maker_warning_suppression(self): def test_manifest_maker_warning_suppression(self):
fixtures = [ fixtures = [
"standard file not found: should have one of foo.py, bar.py", "standard file not found: should have one of foo.py, bar.py",
...@@ -559,17 +550,13 @@ class TestEggInfo(object): ...@@ -559,17 +550,13 @@ class TestEggInfo(object):
for msg in fixtures: for msg in fixtures:
assert manifest_maker._should_suppress_warning(msg) assert manifest_maker._should_suppress_warning(msg)
def _run_install_command(self, tmpdir_cwd, env, cmd=None, output=None): def _run_egg_info_command(self, tmpdir_cwd, env, cmd=None, output=None):
environ = os.environ.copy().update( environ = os.environ.copy().update(
HOME=env.paths['home'], HOME=env.paths['home'],
) )
if cmd is None: if cmd is None:
cmd = [ cmd = [
'install', 'egg_info',
'--home', env.paths['home'],
'--install-lib', env.paths['lib'],
'--install-scripts', env.paths['scripts'],
'--install-data', env.paths['data'],
] ]
code, data = environment.run_setup_py( code, data = environment.run_setup_py(
cmd=cmd, cmd=cmd,
...@@ -581,18 +568,3 @@ class TestEggInfo(object): ...@@ -581,18 +568,3 @@ class TestEggInfo(object):
raise AssertionError(data) raise AssertionError(data)
if output: if output:
assert output in data assert output in data
def _find_egg_info_files(self, root):
class DirList(list):
def __init__(self, files, base):
super(DirList, self).__init__(files)
self.base = base
results = (
DirList(filenames, dirpath)
for dirpath, dirnames, filenames in os.walk(root)
if os.path.basename(dirpath) == 'EGG-INFO'
)
# expect exactly one result
result, = results
return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment