mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Improve according to comments
This commit is contained in:
+6
-5
@@ -595,8 +595,9 @@ class Project(object):
|
||||
"""Get the equivalent package name in pipfile"""
|
||||
key = 'dev-packages' if dev else 'packages'
|
||||
section = self.parsed_pipfile.get(key, {})
|
||||
package_name = pep423_name(package_name)
|
||||
for name in section.keys():
|
||||
if pep423_name(name) == pep423_name(package_name):
|
||||
if pep423_name(name) == package_name:
|
||||
return name
|
||||
return None
|
||||
|
||||
@@ -626,11 +627,11 @@ class Project(object):
|
||||
package = convert_deps_from_pip(package_name)
|
||||
package_name = [k for k in package.keys()][0]
|
||||
name = self.get_package_name_in_pipfile(package_name, dev)
|
||||
if name and name != package_name:
|
||||
# Replace the packge name
|
||||
del p[key][name]
|
||||
if name and converted == '*':
|
||||
# Skip for wildcard version
|
||||
return
|
||||
# Add the package to the group.
|
||||
p[key][package_name] = package[package_name]
|
||||
p[key][name or package_name] = package[package_name]
|
||||
# Write Pipfile.
|
||||
self.write_toml(p)
|
||||
|
||||
|
||||
@@ -592,13 +592,13 @@ tpfd = "*"
|
||||
|
||||
@pytest.mark.install
|
||||
@pytest.mark.run
|
||||
def test_pep423_name_install(self, pypi):
|
||||
def test_normalize_name_install(self, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
contents = """
|
||||
# Pre comment
|
||||
[packages]
|
||||
python_DateUtil = "*" # Inline comment
|
||||
Requests = "==2.14.0" # Inline comment
|
||||
"""
|
||||
f.write(contents)
|
||||
|
||||
@@ -607,18 +607,21 @@ python_DateUtil = "*" # Inline comment
|
||||
|
||||
c = p.pipenv('install requests')
|
||||
assert c.return_code == 0
|
||||
assert 'python_DateUtil' in p.pipfile['packages']
|
||||
c = p.pipenv('install python_dateutil')
|
||||
assert 'requests' not in p.pipfile['packages']
|
||||
assert p.pipfile['packages']['Requests'] == '==2.14.0'
|
||||
c = p.pipenv('install requests==2.18.4')
|
||||
assert c.return_code == 0
|
||||
assert p.pipfile['packages']['Requests'] == '==2.18.4'
|
||||
c = p.pipenv('install python_DateUtil')
|
||||
assert c.return_code == 0
|
||||
assert 'python-dateutil' in p.pipfile['packages']
|
||||
assert 'python_DateUtil' not in p.pipfile['packages']
|
||||
contents = open(p.pipfile_path).read()
|
||||
assert '# Pre comment' in contents
|
||||
assert '# Inline comment' in contents
|
||||
|
||||
@pytest.mark.uninstall
|
||||
@pytest.mark.run
|
||||
def test_pep423_name_uninstall(self, pypi):
|
||||
def test_normalize_name_uninstall(self, pypi):
|
||||
with PipenvInstance(pypi=pypi) as p:
|
||||
with open(p.pipfile_path, 'w') as f:
|
||||
contents = """
|
||||
|
||||
Reference in New Issue
Block a user