-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/record download info #453
Changes from all commits
d1e010c
dbfa932
14502cc
25fcbd9
43ea7d0
7c187ca
a706574
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import os | ||
|
||
from pip.backwardcompat import ConfigParser | ||
from pip.download import path_to_url2 | ||
from tests.test_pip import here, reset_env, run_pip | ||
from tests.path import Path | ||
|
||
|
||
def test_index(): | ||
""" | ||
Test that the info.ini is written and works from an index (PyPI). | ||
""" | ||
env = reset_env() | ||
run_pip('install', '-i http://pypi.python.org/simple/', 'INITools') | ||
|
||
egg_info_dir = None | ||
for x in os.listdir(os.path.join(os.path.dirname(env.venv_path), env.site_packages)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. specifying a particular INITools version would also allow you to construct the exact expected egg-info directory name (like many other tests do) rather than having to search for it with os.listdir. |
||
if x.startswith("INITools-") and x.endswith(".egg-info"): | ||
egg_info_dir = os.path.join(os.path.dirname(env.venv_path), env.site_packages, x) | ||
break | ||
assert egg_info_dir is not None | ||
|
||
infofp = open(os.path.join(os.path.dirname(env.venv_path), env.site_packages, egg_info_dir, "info.ini")) | ||
info = ConfigParser.RawConfigParser() | ||
info.readfp(infofp) | ||
infofp.close() | ||
|
||
assert info.has_section("download") | ||
assert info.get("download", "url").startswith("http://pypi.python.org/packages/source/I/INITools/INITools") | ||
assert info.get("download", "requirement") == "INITools" | ||
|
||
|
||
def test_tarball(): | ||
""" | ||
Test that the info.ini is written and works from an tarball. | ||
""" | ||
env = reset_env() | ||
run_pip('install', 'http://pypi.python.org/packages/source/I/INITools/INITools-0.3.1.tar.gz') | ||
|
||
egg_info_dir = None | ||
for x in os.listdir(os.path.join(os.path.dirname(env.venv_path), env.site_packages)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you know the version of INITools, and you know the Python version, so you can construct the exact egg-info directory name, you don't have to go searching for it like this. |
||
if x.startswith("INITools-") and x.endswith(".egg-info"): | ||
egg_info_dir = os.path.join(os.path.dirname(env.venv_path), env.site_packages, x) | ||
break | ||
assert egg_info_dir is not None | ||
|
||
infofp = open(os.path.join(egg_info_dir, "info.ini")) | ||
info = ConfigParser.RawConfigParser() | ||
info.readfp(infofp) | ||
infofp.close() | ||
|
||
assert info.has_section("download") | ||
assert info.get("download", "url") == "http://pypi.python.org/packages/source/I/INITools/INITools-0.3.1.tar.gz" | ||
assert info.get("download", "requirement") == "http://pypi.python.org/packages/source/I/INITools/INITools-0.3.1.tar.gz" | ||
|
||
|
||
def test_editable(): | ||
""" | ||
Test that the info.ini is written and works from an editable. | ||
""" | ||
env = reset_env() | ||
fspkg = path_to_url2(Path(here) / 'packages' / 'FSPkg') | ||
run_pip('install', '-e', fspkg) | ||
|
||
egg_info_dir = None | ||
for x in os.listdir(Path(here) / 'packages' / 'FSPkg'): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, no need to search like this |
||
if x.startswith("FSPkg") and x.endswith(".egg-info"): | ||
egg_info_dir = os.path.join(Path(here) / 'packages' / 'FSPkg', x) | ||
break | ||
assert egg_info_dir is not None | ||
|
||
infofp = open(os.path.join(egg_info_dir, "info.ini")) | ||
info = ConfigParser.RawConfigParser() | ||
info.readfp(infofp) | ||
infofp.close() | ||
|
||
assert info.has_section("download") | ||
assert info.get("download", "url") == "file:///Users/dstufft/projects/pip/tests/packages/FSPkg" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gonna have to be cleverer with these assertions, the tests have to pass on other machines besides yours :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow I can't believe I did that. That's what I get for trying to do this at like 1am. |
||
assert info.get("download", "requirement") == "--editable=file:///Users/dstufft/projects/pip/tests/packages/FSPkg" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
specifying a particular INITools version makes the test more future-proof