import stat
import time
-from setuptools.build_meta import prepare_metadata_for_build_wheel
from setuptools.command.egg_info import (
egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision,
)
from . import contexts
-def _run_egg_info_command(tmpdir_cwd, env, cmd=None, output=None):
- environ = os.environ.copy().update(
- HOME=env.paths['home'],
- )
- if cmd is None:
- cmd = [
- 'egg_info',
- ]
- code, data = environment.run_setup_py(
- cmd=cmd,
- pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
- data_stream=1,
- env=environ,
- )
- assert not code, data
-
- if output:
- assert output in data
-
-
class Environment(str):
pass
def test_expected_files_produced(self, tmpdir_cwd, env):
self._create_project()
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
actual = os.listdir('foo.egg-info')
expected = [
# currently configured to use a subprocess, the actual traceback
# object is lost and we need to parse it from stderr
with pytest.raises(AssertionError) as exc:
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
# Hopefully this is not too fragile: the only argument to the
# assertion error should be a traceback, ending with:
"""Ensure timestamps are updated when the command is re-run."""
self._create_project()
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
timestamp_a = os.path.getmtime('foo.egg-info')
# arbitrary sleep just to handle *really* fast systems
time.sleep(.001)
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
timestamp_b = os.path.getmtime('foo.egg-info')
assert timestamp_a != timestamp_b
'usage.rst': "Run 'hi'",
}
})
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
egg_info_dir = os.path.join('.', 'foo.egg-info')
sources_txt = os.path.join(egg_info_dir, 'SOURCES.txt')
with open(sources_txt) as f:
self, tmpdir_cwd, env, requires, use_setup_cfg,
expected_requires, install_cmd_kwargs):
self._setup_script_with_requires(requires, use_setup_cfg)
- _run_egg_info_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')
requires_txt = os.path.join(egg_info_dir, 'requires.txt')
if os.path.exists(requires_txt):
req = 'install_requires={"fake-factory==0.5.2", "pytz"}'
self._setup_script_with_requires(req)
with pytest.raises(AssertionError):
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
def test_extras_require_with_invalid_marker(self, tmpdir_cwd, env):
tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},'
req = tmpl.format(marker=self.invalid_marker)
self._setup_script_with_requires(req)
with pytest.raises(AssertionError):
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env):
req = tmpl.format(marker=self.invalid_marker)
self._setup_script_with_requires(req)
with pytest.raises(AssertionError):
- _run_egg_info_command(tmpdir_cwd, env)
+ self._run_egg_info_command(tmpdir_cwd, env)
assert glob.glob(os.path.join(env.paths['lib'], 'barbazquux*')) == []
def test_provides_extra(self, tmpdir_cwd, env):
sources = f.read().split('\n')
assert 'setup.py' in sources
- @pytest.mark.parametrize(
- ('make_metadata_path', 'run_command'),
- [
- (
- lambda env: os.path.join('.', 'foo.egg-info', 'PKG-INFO'),
- lambda tmpdir_cwd, env: _run_egg_info_command(tmpdir_cwd, env)
- ),
- (
- lambda env: os.path.join(env, 'foo.dist-info', 'METADATA'),
- lambda tmpdir_cwd, env: prepare_metadata_for_build_wheel(env)
- )
- ]
- )
- def test_egg_info_tag_only_once(
- self, tmpdir_cwd, env, make_metadata_path, run_command
- ):
+ def _run_egg_info_command(self, tmpdir_cwd, env, cmd=None, output=None):
+ environ = os.environ.copy().update(
+ HOME=env.paths['home'],
+ )
+ if cmd is None:
+ cmd = [
+ 'egg_info',
+ ]
+ code, data = environment.run_setup_py(
+ cmd=cmd,
+ pypath=os.pathsep.join([env.paths['lib'], str(tmpdir_cwd)]),
+ data_stream=1,
+ env=environ,
+ )
+ assert not code, data
+
+ if output:
+ assert output in data
+
+ def test_egg_info_tag_only_once(self, tmpdir_cwd, env):
self._create_project()
build_files({
'setup.cfg': DALS("""
tag_svn_revision = 0
"""),
})
- run_command(tmpdir_cwd, env)
- with open(make_metadata_path(env)) as metadata_file:
- metadata_lines = metadata_file.read().split('\n')
- assert 'Version: 0.0.0.dev0' in metadata_lines
+ self._run_egg_info_command(tmpdir_cwd, env)
+ egg_info_dir = os.path.join('.', 'foo.egg-info')
+ with open(os.path.join(egg_info_dir, 'PKG-INFO')) as pkginfo_file:
+ pkg_info_lines = pkginfo_file.read().split('\n')
+ assert 'Version: 0.0.0.dev0' in pkg_info_lines
def test_get_pkg_info_revision_deprecated(self):
pytest.warns(EggInfoDeprecationWarning, get_pkg_info_revision)