diff options
| author | Jeremy Bowman <github@portabase.org> | 2018-05-17 13:39:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-17 13:39:50 -0400 |
| commit | 50e3ba6e94a655dec916c9f9fe28b7434622547f (patch) | |
| tree | 84e39dc3b2495dbe01fc965ea837fe6613f013ba /setuptools/tests | |
| parent | 4166bc903fadb1726c2851d50b601357878e95b1 (diff) | |
| parent | c608faf8336bcb94624545e6c07a702afcb92b2d (diff) | |
| download | python-setuptools-git-50e3ba6e94a655dec916c9f9fe28b7434622547f.tar.gz | |
Merge pull request #1368 from jmbowman/jmbowman/no_network_in_tests
Don't require network in tests
Diffstat (limited to 'setuptools/tests')
| -rw-r--r-- | setuptools/tests/test_egg_info.py | 66 |
1 files changed, 19 insertions, 47 deletions
diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index 2a070deb..8b3b90f7 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -128,11 +128,11 @@ class TestEggInfo(object): 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._run_install_command(tmpdir_cwd, env) - actual = self._find_egg_info_files(env.paths['lib']) + self._run_egg_info_command(tmpdir_cwd, env) + actual = os.listdir('foo.egg-info') expected = [ 'PKG-INFO', @@ -154,8 +154,8 @@ class TestEggInfo(object): 'usage.rst': "Run 'hi'", } }) - self._run_install_command(tmpdir_cwd, env) - egg_info_dir = self._find_egg_info_files(env.paths['lib']).base + 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: assert 'docs/usage.rst' in f.read().split('\n') @@ -233,27 +233,27 @@ class TestEggInfo(object): ''' install_requires_deterministic - install_requires=["fake-factory==0.5.2", "pytz"] + install_requires=["wheel>=0.5", "pytest"] [options] install_requires = - fake-factory==0.5.2 - pytz + wheel>=0.5 + pytest - fake-factory==0.5.2 - pytz + wheel>=0.5 + pytest ''', ''' install_requires_ordered - install_requires=["fake-factory>=1.12.3,!=2.0"] + install_requires=["pytest>=3.0.2,!=10.9999"] [options] install_requires = - fake-factory>=1.12.3,!=2.0 + pytest>=3.0.2,!=10.9999 - fake-factory!=2.0,>=1.12.3 + pytest!=10.9999,>=3.0.2 ''', ''' @@ -394,7 +394,7 @@ class TestEggInfo(object): self, tmpdir_cwd, env, requires, use_setup_cfg, expected_requires, install_cmd_kwargs): 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') requires_txt = os.path.join(egg_info_dir, 'requires.txt') if os.path.exists(requires_txt): @@ -414,14 +414,14 @@ class TestEggInfo(object): req = 'install_requires={"fake-factory==0.5.2", "pytz"}' self._setup_script_with_requires(req) 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): tmpl = 'extras_require={{":{marker}": ["barbazquux"]}},' req = tmpl.format(marker=self.invalid_marker) self._setup_script_with_requires(req) 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*')) == [] def test_extras_require_with_invalid_marker_in_req(self, tmpdir_cwd, env): @@ -429,7 +429,7 @@ class TestEggInfo(object): req = tmpl.format(marker=self.invalid_marker) self._setup_script_with_requires(req) 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*')) == [] def test_provides_extra(self, tmpdir_cwd, env): @@ -541,15 +541,6 @@ class TestEggInfo(object): assert 'Requires-Python: >=2.7.12' 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): fixtures = [ "standard file not found: should have one of foo.py, bar.py", @@ -559,17 +550,13 @@ class TestEggInfo(object): for msg in fixtures: 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( HOME=env.paths['home'], ) if cmd is None: cmd = [ - 'install', - '--home', env.paths['home'], - '--install-lib', env.paths['lib'], - '--install-scripts', env.paths['scripts'], - '--install-data', env.paths['data'], + 'egg_info', ] code, data = environment.run_setup_py( cmd=cmd, @@ -581,18 +568,3 @@ class TestEggInfo(object): raise AssertionError(data) if output: 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 |
