aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2018-03-06 12:24:12 -0500
committerJason R. Coombs <jaraco@jaraco.com>2018-03-06 12:24:12 -0500
commite065e9012612f3e0b8713fd61d298126f7fcfa21 (patch)
treee45822ca5a3038c478734069ecb1e00792e76986 /pkg_resources
parentc9ecd46f7b8a2a70a2fdf0535caf582602341042 (diff)
downloadexternal_python_setuptools-e065e9012612f3e0b8713fd61d298126f7fcfa21.tar.gz
external_python_setuptools-e065e9012612f3e0b8713fd61d298126f7fcfa21.tar.bz2
external_python_setuptools-e065e9012612f3e0b8713fd61d298126f7fcfa21.zip
Feed the hobgoblins (delint).
Diffstat (limited to 'pkg_resources')
-rw-r--r--pkg_resources/__init__.py2
-rw-r--r--pkg_resources/tests/test_find_distributions.py1
-rw-r--r--pkg_resources/tests/test_pkg_resources.py6
-rw-r--r--pkg_resources/tests/test_resources.py41
-rw-r--r--pkg_resources/tests/test_working_set.py10
5 files changed, 42 insertions, 18 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index c9b2d251..92272f20 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -1307,7 +1307,7 @@ class ResourceManager:
target_path = os.path.join(extract_path, archive_name + '-tmp', *names)
try:
_bypass_ensure_directory(target_path)
- except:
+ except Exception:
self.extraction_error()
self._warn_unsafe_extraction_path(extract_path)
diff --git a/pkg_resources/tests/test_find_distributions.py b/pkg_resources/tests/test_find_distributions.py
index 97999b33..d735c590 100644
--- a/pkg_resources/tests/test_find_distributions.py
+++ b/pkg_resources/tests/test_find_distributions.py
@@ -13,6 +13,7 @@ setuptools.setup(
)
""".lstrip()
+
class TestFindDistributions:
@pytest.fixture
diff --git a/pkg_resources/tests/test_pkg_resources.py b/pkg_resources/tests/test_pkg_resources.py
index f2c00b29..7442b79f 100644
--- a/pkg_resources/tests/test_pkg_resources.py
+++ b/pkg_resources/tests/test_pkg_resources.py
@@ -154,8 +154,10 @@ class TestIndependence:
lines = (
'import pkg_resources',
'import sys',
- 'assert "setuptools" not in sys.modules, '
- '"setuptools was imported"',
+ (
+ 'assert "setuptools" not in sys.modules, '
+ '"setuptools was imported"'
+ ),
)
cmd = [sys.executable, '-c', '; '.join(lines)]
subprocess.check_call(cmd)
diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py
index dcd2f42c..05438219 100644
--- a/pkg_resources/tests/test_resources.py
+++ b/pkg_resources/tests/test_resources.py
@@ -11,7 +11,8 @@ import pytest
from pkg_resources.extern import packaging
import pkg_resources
-from pkg_resources import (parse_requirements, VersionConflict, parse_version,
+from pkg_resources import (
+ parse_requirements, VersionConflict, parse_version,
Distribution, EntryPoint, Requirement, safe_version, safe_name,
WorkingSet)
@@ -51,7 +52,8 @@ class TestDistro:
assert list(ad) == ['foopkg']
# Distributions sort by version
- assert [dist.version for dist in ad['FooPkg']] == ['1.4', '1.3-1', '1.2']
+ expected = ['1.4', '1.3-1', '1.2']
+ assert [dist.version for dist in ad['FooPkg']] == expected
# Removing a distribution leaves sequence alone
ad.remove(ad['FooPkg'][1])
@@ -97,7 +99,10 @@ class TestDistro:
def testDistroBasics(self):
d = Distribution(
"/some/path",
- project_name="FooPkg", version="1.3-1", py_version="2.4", platform="win32"
+ project_name="FooPkg",
+ version="1.3-1",
+ py_version="2.4",
+ platform="win32",
)
self.checkFooPkg(d)
@@ -113,10 +118,11 @@ class TestDistro:
def testDistroMetadata(self):
d = Distribution(
- "/some/path", project_name="FooPkg", py_version="2.4", platform="win32",
+ "/some/path", project_name="FooPkg",
+ py_version="2.4", platform="win32",
metadata=Metadata(
('PKG-INFO', "Metadata-Version: 1.0\nVersion: 1.3-1\n")
- )
+ ),
)
self.checkFooPkg(d)
@@ -164,7 +170,10 @@ class TestDistro:
ad.add(Baz)
# Activation list now includes resolved dependency
- assert list(ws.resolve(parse_requirements("Foo[bar]"), ad)) == [Foo, Baz]
+ assert (
+ list(ws.resolve(parse_requirements("Foo[bar]"), ad))
+ == [Foo, Baz]
+ )
# Requests for conflicting versions produce VersionConflict
with pytest.raises(VersionConflict) as vc:
ws.resolve(parse_requirements("Foo==1.2\nFoo!=1.2"), ad)
@@ -415,7 +424,8 @@ class TestEntryPoints:
submap_expect = dict(
feature1=EntryPoint('feature1', 'somemodule', ['somefunction']),
- feature2=EntryPoint('feature2', 'another.module', ['SomeClass'], ['extra1', 'extra2']),
+ feature2=EntryPoint(
+ 'feature2', 'another.module', ['SomeClass'], ['extra1', 'extra2']),
feature3=EntryPoint('feature3', 'this.module', extras=['something'])
)
submap_str = """
@@ -518,11 +528,17 @@ class TestRequirements:
Requirement.parse('setuptools').project_name == 'setuptools')
# setuptools 0.7 and higher means setuptools.
assert (
- Requirement.parse('setuptools == 0.7').project_name == 'setuptools')
+ Requirement.parse('setuptools == 0.7').project_name
+ == 'setuptools'
+ )
assert (
- Requirement.parse('setuptools == 0.7a1').project_name == 'setuptools')
+ Requirement.parse('setuptools == 0.7a1').project_name
+ == 'setuptools'
+ )
assert (
- Requirement.parse('setuptools >= 0.7').project_name == 'setuptools')
+ Requirement.parse('setuptools >= 0.7').project_name
+ == 'setuptools'
+ )
class TestParsing:
@@ -552,7 +568,7 @@ class TestParsing:
"""
assert (
list(pkg_resources.split_sections(sample))
- ==
+ ==
[
(None, ["x"]),
("Y", ["z", "a"]),
@@ -838,7 +854,8 @@ class TestNamespaces:
subpkg = nspkg / 'subpkg'
subpkg.ensure_dir()
(nspkg / '__init__.py').write_text(self.ns_str, encoding='utf-8')
- (subpkg / '__init__.py').write_text(vers_str % number, encoding='utf-8')
+ (subpkg / '__init__.py').write_text(
+ vers_str % number, encoding='utf-8')
import nspkg.subpkg
import nspkg
diff --git a/pkg_resources/tests/test_working_set.py b/pkg_resources/tests/test_working_set.py
index 422a7283..42ddcc86 100644
--- a/pkg_resources/tests/test_working_set.py
+++ b/pkg_resources/tests/test_working_set.py
@@ -1,6 +1,7 @@
import inspect
import re
import textwrap
+import functools
import pytest
@@ -15,6 +16,7 @@ def strip_comments(s):
if l.strip() and not l.strip().startswith('#')
)
+
def parse_distributions(s):
'''
Parse a series of distribution specs of the form:
@@ -31,7 +33,8 @@ def parse_distributions(s):
yield 2 distributions:
- project_name=foo, version=0.2
- - project_name=bar, version=1.0, requires=['foo>=3.0', 'baz; extra=="feature"']
+ - project_name=bar, version=1.0,
+ requires=['foo>=3.0', 'baz; extra=="feature"']
'''
s = s.strip()
for spec in re.split('\n(?=[^\s])', s):
@@ -42,7 +45,7 @@ def parse_distributions(s):
name, version = fields.pop(0).split('-')
if fields:
requires = textwrap.dedent(fields.pop(0))
- metadata=Metadata(('requires.txt', requires))
+ metadata = Metadata(('requires.txt', requires))
else:
metadata = None
dist = pkg_resources.Distribution(project_name=name,
@@ -467,7 +470,8 @@ def test_working_set_resolve(installed_dists, installable_dists, requirements,
replace_conflicting, resolved_dists_or_exception):
ws = pkg_resources.WorkingSet([])
list(map(ws.add, installed_dists))
- resolve_call = lambda: ws.resolve(
+ resolve_call = functools.partial(
+ ws.resolve,
requirements, installer=FakeInstaller(installable_dists),
replace_conflicting=replace_conflicting,
)