1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Fix tests module with flake8-bugbear

This commit is contained in:
Devesh Kumar Singh 2020-06-05 02:41:08 +05:30
parent 6716a2bec5
commit db11f83e2a
8 changed files with 14 additions and 11 deletions

View file

@ -1358,7 +1358,7 @@ def test_install_builds_wheels(script, data, with_wheel):
# Must have installed it all
assert expected in str(res), str(res)
wheels = []
for top, dirs, files in os.walk(wheels_cache):
for _, _, files in os.walk(wheels_cache):
wheels.extend(files)
# and built wheels for upper and wheelbroken
assert "Building wheel for upper" in str(res), str(res)

View file

@ -6,7 +6,8 @@ from pip._internal.req import InstallRequirement
from tests.lib import make_test_finder, path_to_url, windows_workaround_7667
def make_project(tmpdir, requires=[], backend=None, backend_path=None):
def make_project(tmpdir, requires=None, backend=None, backend_path=None):
requires = requires or []
project_dir = tmpdir / 'project'
project_dir.mkdir()
buildsys = {'requires': requires}

View file

@ -41,7 +41,7 @@ def do_commit(script, dest):
def add_commits(script, dest, count):
"""Return a list of the commit hashes from oldest to newest."""
shas = []
for index in range(count):
for _ in range(count):
sha = do_commit(script, dest)
shas.append(sha)

View file

@ -264,9 +264,11 @@ class TestPipResult(object):
def __str__(self):
return str(self._impl)
def assert_installed(self, pkg_name, editable=True, with_files=[],
without_files=[], without_egg_link=False,
def assert_installed(self, pkg_name, editable=True, with_files=None,
without_files=None, without_egg_link=False,
use_user_site=False, sub_dir=False):
with_files = with_files or []
without_files = without_files or []
e = self.test_env
if editable:

View file

@ -50,14 +50,14 @@ def test_cases(data):
def test_new_resolver_requirement_has_name(test_cases, factory):
"""All requirements should have a name"""
for spec, name, matches in test_cases:
for spec, name, _ in test_cases:
req = factory.make_requirement_from_spec(spec, comes_from=None)
assert req.name == name
def test_new_resolver_correct_number_of_matches(test_cases, factory):
"""Requirements should return the correct number of candidates"""
for spec, name, match_count in test_cases:
for spec, _, match_count in test_cases:
req = factory.make_requirement_from_spec(spec, comes_from=None)
matches = factory.find_candidates([req], SpecifierSet())
assert len(list(matches)) == match_count
@ -66,7 +66,7 @@ def test_new_resolver_correct_number_of_matches(test_cases, factory):
def test_new_resolver_candidates_match_requirement(test_cases, factory):
"""Candidates returned from find_candidates should satisfy the requirement
"""
for spec, name, matches in test_cases:
for spec, _, _ in test_cases:
req = factory.make_requirement_from_spec(spec, comes_from=None)
for c in factory.find_candidates([req], SpecifierSet()):
assert isinstance(c, Candidate)

View file

@ -561,7 +561,7 @@ class TestParseRequirements(object):
"""
# this requirements file just contains a comment previously this has
# failed in py3: https://github.com/pypa/pip/issues/760
for req in parse_reqfile(
for _ in parse_reqfile(
'https://raw.githubusercontent.com/pypa/'
'pip-test-package/master/'
'tests/req_just_comment.txt', session=PipSession()):

View file

@ -21,7 +21,7 @@ def zip_dir():
# type: (Path) -> ZipFile
buf = BytesIO()
with ZipFile(buf, "w", allowZip64=True) as z:
for dirpath, dirnames, filenames in os.walk(path):
for dirpath, _, filenames in os.walk(path):
for filename in filenames:
file_path = os.path.join(path, dirpath, filename)
# Zip files must always have / as path separator

View file

@ -68,7 +68,7 @@ def lint_yml(yml_file, verbose=False):
check_dict(data, required=['cases'], optional=['base'])
base = data.get("base", {})
cases = data["cases"]
for i, case_template in enumerate(cases):
for _, case_template in enumerate(cases):
case = base.copy()
case.update(case_template)
lint_case(case, verbose)