mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge branch 'master' into unused-vendors
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Normalize the package names to lowercase when comparing used and in-Pipfile packages.
|
||||
+5
-3
@@ -242,7 +242,9 @@ def import_from_code(path="."):
|
||||
|
||||
rs = []
|
||||
try:
|
||||
for r in pipreqs.get_all_imports(path):
|
||||
for r in pipreqs.get_all_imports(
|
||||
path, encoding="utf-8", extra_ignore_dirs=[".venv"]
|
||||
):
|
||||
if r not in BAD_PACKAGES:
|
||||
rs.append(r)
|
||||
pkg_names = pipreqs.get_pkg_names(rs)
|
||||
@@ -2537,8 +2539,8 @@ def do_check(
|
||||
if not args:
|
||||
args = []
|
||||
if unused:
|
||||
deps_required = [k for k in project.packages.keys()]
|
||||
deps_needed = import_from_code(unused)
|
||||
deps_required = [k.lower() for k in project.packages.keys()]
|
||||
deps_needed = [k.lower() for k in import_from_code(unused)]
|
||||
for dep in deps_needed:
|
||||
try:
|
||||
deps_required.remove(dep)
|
||||
|
||||
@@ -217,20 +217,20 @@ def test_install_parse_error(PipenvInstance, pypi):
|
||||
@pytest.mark.code
|
||||
@pytest.mark.check
|
||||
@pytest.mark.unused
|
||||
@pytest.mark.skip(reason="non-deterministic")
|
||||
@pytest.mark.needs_internet(reason='required by check')
|
||||
def test_check_unused(PipenvInstance, pypi):
|
||||
with PipenvInstance(chdir=True, pypi=pypi) as p:
|
||||
with open('__init__.py', 'w') as f:
|
||||
contents = """
|
||||
import tablib
|
||||
import records
|
||||
import flask
|
||||
""".strip()
|
||||
f.write(contents)
|
||||
p.pipenv('install requests')
|
||||
p.pipenv('install tablib')
|
||||
p.pipenv('install records')
|
||||
p.pipenv('install requests tablib flask')
|
||||
|
||||
assert all(pkg in p.pipfile['packages'] for pkg in ['requests', 'tablib', 'records'])
|
||||
assert all(pkg in p.pipfile['packages'] for pkg in ['requests', 'tablib', 'flask'])
|
||||
|
||||
c = p.pipenv('check --unused .')
|
||||
assert 'tablib' not in c.out
|
||||
assert 'flask' not in c.out
|
||||
|
||||
Reference in New Issue
Block a user