Skip to content

Commit 5cd8698

Browse files
committed
Feed the hobgoblins (delint).
1 parent 050c0cb commit 5cd8698

22 files changed

+183
-140
lines changed

setuptools/tests/files.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66

77
def build_files(file_defs, prefix=""):
88
"""
9-
Build a set of files/directories, as described by the file_defs dictionary.
9+
Build a set of files/directories, as described by the
10+
file_defs dictionary.
1011
11-
Each key/value pair in the dictionary is interpreted as a filename/contents
12-
pair. If the contents value is a dictionary, a directory is created, and the
12+
Each key/value pair in the dictionary is interpreted as
13+
a filename/contents
14+
pair. If the contents value is a dictionary, a directory
15+
is created, and the
1316
dictionary interpreted as the files within it, recursively.
1417
1518
For example:

setuptools/tests/server.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ class IndexServer(BaseHTTPServer.HTTPServer):
1919
s.stop()
2020
"""
2121

22-
def __init__(self, server_address=('', 0),
22+
def __init__(
23+
self, server_address=('', 0),
2324
RequestHandlerClass=SimpleHTTPServer.SimpleHTTPRequestHandler):
24-
BaseHTTPServer.HTTPServer.__init__(self, server_address,
25-
RequestHandlerClass)
25+
BaseHTTPServer.HTTPServer.__init__(
26+
self, server_address, RequestHandlerClass)
2627
self._run = True
2728

2829
def start(self):
@@ -56,10 +57,11 @@ class MockServer(BaseHTTPServer.HTTPServer, threading.Thread):
5657
A simple HTTP Server that records the requests made to it.
5758
"""
5859

59-
def __init__(self, server_address=('', 0),
60+
def __init__(
61+
self, server_address=('', 0),
6062
RequestHandlerClass=RequestRecorder):
61-
BaseHTTPServer.HTTPServer.__init__(self, server_address,
62-
RequestHandlerClass)
63+
BaseHTTPServer.HTTPServer.__init__(
64+
self, server_address, RequestHandlerClass)
6365
threading.Thread.__init__(self)
6466
self.setDaemon(True)
6567
self.requests = []

setuptools/tests/test_build_clib.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import pytest
2-
import os
3-
import shutil
42

53
import mock
64
from distutils.errors import DistutilsSetupError
@@ -40,13 +38,14 @@ def test_build_libraries(self, mock_newer):
4038
# with that out of the way, let's see if the crude dependency
4139
# system works
4240
cmd.compiler = mock.MagicMock(spec=cmd.compiler)
43-
mock_newer.return_value = ([],[])
41+
mock_newer.return_value = ([], [])
4442

4543
obj_deps = {'': ('global.h',), 'example.c': ('example.h',)}
46-
libs = [('example', {'sources': ['example.c'] ,'obj_deps': obj_deps})]
44+
libs = [('example', {'sources': ['example.c'], 'obj_deps': obj_deps})]
4745

4846
cmd.build_libraries(libs)
49-
assert [['example.c', 'global.h', 'example.h']] in mock_newer.call_args[0]
47+
assert [['example.c', 'global.h', 'example.h']] in \
48+
mock_newer.call_args[0]
5049
assert not cmd.compiler.compile.called
5150
assert cmd.compiler.create_static_lib.call_count == 1
5251

setuptools/tests/test_config.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from . import py2_only, py3_only
99
from .textwrap import DALS
1010

11+
1112
class ErrConfigHandler(ConfigHandler):
1213
"""Erroneous handler. Fails to implement required methods."""
1314

@@ -18,8 +19,8 @@ def make_package_dir(name, base_dir, ns=False):
1819
dir_package = dir_package.mkdir(dir_name)
1920
init_file = None
2021
if not ns:
21-
init_file = dir_package.join('__init__.py')
22-
init_file.write('')
22+
init_file = dir_package.join('__init__.py')
23+
init_file.write('')
2324
return dir_package, init_file
2425

2526

@@ -308,7 +309,7 @@ def test_version_file(self, tmpdir):
308309
tmpdir.join('fake_package', 'version.txt').write('1.2.3\n4.5.6\n')
309310
with pytest.raises(DistutilsOptionError):
310311
with get_dist(tmpdir) as dist:
311-
_ = dist.metadata.version
312+
dist.metadata.version
312313

313314
def test_version_with_package_dir_simple(self, tmpdir):
314315

@@ -451,7 +452,7 @@ def test_basic(self, tmpdir):
451452
'tests_require = mock==0.7.2; pytest\n'
452453
'setup_requires = docutils>=0.3; spack ==1.1, ==1.3; there\n'
453454
'dependency_links = http://some.com/here/1, '
454-
'http://some.com/there/2\n'
455+
'http://some.com/there/2\n'
455456
'python_requires = >=1.0, !=2.8\n'
456457
'py_modules = module1, module2\n'
457458
)
@@ -659,7 +660,7 @@ def test_find_namespace_directive(self, tmpdir):
659660
dir_sub_two, _ = make_package_dir('sub_two', dir_package, ns=True)
660661

661662
with get_dist(tmpdir) as dist:
662-
assert set(dist.packages) == {
663+
assert set(dist.packages) == {
663664
'fake_package', 'fake_package.sub_two', 'fake_package.sub_one'
664665
}
665666

@@ -711,7 +712,7 @@ def test_entry_points(self, tmpdir):
711712
tmpdir,
712713
'[options.entry_points]\n'
713714
'group1 = point1 = pack.module:func, '
714-
'.point2 = pack.module2:func_rest [rest]\n'
715+
'.point2 = pack.module2:func_rest [rest]\n'
715716
'group2 = point3 = pack.module:func2\n'
716717
)
717718

@@ -757,7 +758,10 @@ def test_data_files(self, tmpdir):
757758
]
758759
assert sorted(dist.data_files) == sorted(expected)
759760

761+
760762
saved_dist_init = _Distribution.__init__
763+
764+
761765
class TestExternalSetters:
762766
# During creation of the setuptools Distribution() object, we call
763767
# the init of the parent distutils Distribution object via

setuptools/tests/test_depends.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
class TestGetModuleConstant:
77

8-
def test_basic(self):
9-
"""
10-
Invoke get_module_constant on a module in
11-
the test package.
12-
"""
13-
mod_name = 'setuptools.tests.mod_with_constant'
14-
val = depends.get_module_constant(mod_name, 'value')
15-
assert val == 'three, sir!'
16-
assert 'setuptools.tests.mod_with_constant' not in sys.modules
8+
def test_basic(self):
9+
"""
10+
Invoke get_module_constant on a module in
11+
the test package.
12+
"""
13+
mod_name = 'setuptools.tests.mod_with_constant'
14+
val = depends.get_module_constant(mod_name, 'value')
15+
assert val == 'three, sir!'
16+
assert 'setuptools.tests.mod_with_constant' not in sys.modules

setuptools/tests/test_dist.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import pytest
1616

17+
1718
def test_dist_fetch_build_egg(tmpdir):
1819
"""
1920
Check multiple calls to `Distribution.fetch_build_egg` work as expected.
@@ -90,30 +91,32 @@ def merge_dicts(d1, d2):
9091
'classifiers': [
9192
'Programming Language :: Python :: 3',
9293
'Programming Language :: Python :: 3.7',
93-
'License :: OSI Approved :: MIT License'
94-
]})),
94+
'License :: OSI Approved :: MIT License',
95+
]})),
9596
('Metadata version 1.1: Download URL', merge_dicts(base_attrs, {
9697
'download_url': 'https://example.com'
9798
})),
9899
('Metadata Version 1.2: Requires-Python', merge_dicts(base_attrs, {
99100
'python_requires': '>=3.7'
100101
})),
101-
pytest.param('Metadata Version 1.2: Project-Url',
102+
pytest.param(
103+
'Metadata Version 1.2: Project-Url',
102104
merge_dicts(base_attrs, {
103105
'project_urls': {
104106
'Foo': 'https://example.bar'
105107
}
106108
}), marks=pytest.mark.xfail(
107109
reason="Issue #1578: project_urls not read"
108-
)),
110+
)),
109111
('Metadata Version 2.1: Long Description Content Type',
110112
merge_dicts(base_attrs, {
111113
'long_description_content_type': 'text/x-rst; charset=UTF-8'
112114
})),
113-
pytest.param('Metadata Version 2.1: Provides Extra',
115+
pytest.param(
116+
'Metadata Version 2.1: Provides Extra',
114117
merge_dicts(base_attrs, {
115118
'provides_extras': ['foo', 'bar']
116-
}), marks=pytest.mark.xfail(reason="provides_extras not read")),
119+
}), marks=pytest.mark.xfail(reason="provides_extras not read")),
117120
('Missing author, missing author e-mail',
118121
{'name': 'foo', 'version': '1.0.0'}),
119122
('Missing author',

setuptools/tests/test_easy_install.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
import io
1616
import zipfile
1717
import mock
18-
from setuptools.command.easy_install import EasyInstallDeprecationWarning, ScriptWriter, WindowsScriptWriter
18+
from setuptools.command.easy_install import (
19+
EasyInstallDeprecationWarning, ScriptWriter, WindowsScriptWriter,
20+
)
1921
import time
2022
from setuptools.extern import six
2123
from setuptools.extern.six.moves import urllib
@@ -287,7 +289,6 @@ def test_script_install(self, sdist_script, tmpdir, monkeypatch):
287289
cmd.easy_install(sdist_script)
288290
assert (target / 'mypkg_script').exists()
289291

290-
291292
def test_dist_get_script_args_deprecated(self):
292293
with pytest.warns(EasyInstallDeprecationWarning):
293294
ScriptWriter.get_script_args(None, None)
@@ -304,6 +305,7 @@ def test_dist_WindowsScriptWriter_get_writer_deprecated(self):
304305
with pytest.warns(EasyInstallDeprecationWarning):
305306
WindowsScriptWriter.get_writer()
306307

308+
307309
@pytest.mark.filterwarnings('ignore:Unbuilt egg')
308310
class TestPTHFileWriter:
309311
def test_add_from_cwd_site_sets_dirty(self):

setuptools/tests/test_egg_info.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import datetime
21
import sys
32
import ast
43
import os
@@ -7,7 +6,9 @@
76
import stat
87
import time
98

10-
from setuptools.command.egg_info import egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision
9+
from setuptools.command.egg_info import (
10+
egg_info, manifest_maker, EggInfoDeprecationWarning, get_pkg_info_revision,
11+
)
1112
from setuptools.dist import Distribution
1213
from setuptools.extern.six.moves import map
1314

setuptools/tests/test_find_packages.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from setuptools.extern.six import PY3
1313
from setuptools import find_packages
1414
if PY3:
15-
from setuptools import find_namespace_packages
15+
from setuptools import find_namespace_packages
1616

17-
# modeled after CPython's test.support.can_symlink
1817

18+
# modeled after CPython's test.support.can_symlink
1919
def can_symlink():
2020
TESTFN = tempfile.mktemp()
2121
symlink_path = TESTFN + "can_symlink"
@@ -164,12 +164,14 @@ def test_pep420_ns_package(self):
164164
def test_pep420_ns_package_no_includes(self):
165165
packages = find_namespace_packages(
166166
self.dist_dir, exclude=['pkg.subpkg.assets'])
167-
self._assert_packages(packages, ['docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg'])
167+
self._assert_packages(
168+
packages, ['docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg'])
168169

169170
@py3_only
170171
def test_pep420_ns_package_no_includes_or_excludes(self):
171172
packages = find_namespace_packages(self.dist_dir)
172-
expected = ['docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg', 'pkg.subpkg.assets']
173+
expected = [
174+
'docs', 'pkg', 'pkg.nspkg', 'pkg.subpkg', 'pkg.subpkg.assets']
173175
self._assert_packages(packages, expected)
174176

175177
@py3_only
@@ -185,4 +187,3 @@ def test_pep420_ns_package_no_non_package_dirs(self):
185187
shutil.rmtree(os.path.join(self.dist_dir, 'pkg/subpkg/assets'))
186188
packages = find_namespace_packages(self.dist_dir)
187189
self._assert_packages(packages, ['pkg', 'pkg.nspkg', 'pkg.subpkg'])
188-

setuptools/tests/test_install_scripts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ def test_sys_executable_escaping_win32(self, tmpdir, monkeypatch):
6464
@pytest.mark.skipif(sys.platform == 'win32', reason='non-Windows only')
6565
def test_executable_with_spaces_escaping_unix(self, tmpdir):
6666
"""
67-
Ensure that shebang on Unix is not quoted, even when a value with spaces
67+
Ensure that shebang on Unix is not quoted, even when
68+
a value with spaces
6869
is specified using --executable.
6970
"""
7071
expected = '#!%s\n' % self.unix_spaces_exe
@@ -77,7 +78,8 @@ def test_executable_with_spaces_escaping_unix(self, tmpdir):
7778
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows only')
7879
def test_executable_arg_escaping_win32(self, tmpdir):
7980
"""
80-
Ensure that shebang on Windows is quoted when getting a path with spaces
81+
Ensure that shebang on Windows is quoted when
82+
getting a path with spaces
8183
from --executable, that is itself properly quoted.
8284
"""
8385
expected = '#!"%s"\n' % self.win32_exe

setuptools/tests/test_integration.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
import glob
77
import os
88
import sys
9+
import re
10+
import subprocess
11+
import functools
12+
import tarfile
13+
import zipfile
914

1015
from setuptools.extern.six.moves import urllib
1116
import pytest
@@ -114,15 +119,12 @@ def test_pyuri(install_context):
114119
assert os.path.exists(os.path.join(pyuri.location, 'pyuri', 'uri.regex'))
115120

116121

117-
import re
118-
import subprocess
119-
import functools
120-
import tarfile, zipfile
122+
build_deps = ['appdirs', 'packaging', 'pyparsing', 'six']
121123

122124

123-
build_deps = ['appdirs', 'packaging', 'pyparsing', 'six']
124125
@pytest.mark.parametrize("build_dep", build_deps)
125-
@pytest.mark.skipif(sys.version_info < (3, 6), reason='run only on late versions')
126+
@pytest.mark.skipif(
127+
sys.version_info < (3, 6), reason='run only on late versions')
126128
def test_build_deps_on_distutils(request, tmpdir_factory, build_dep):
127129
"""
128130
All setuptools build dependencies must build without
@@ -149,13 +151,16 @@ def install(pkg_dir, install_dir):
149151
breaker.write('raise ImportError()')
150152
cmd = [sys.executable, 'setup.py', 'install', '--prefix', install_dir]
151153
env = dict(os.environ, PYTHONPATH=pkg_dir)
152-
output = subprocess.check_output(cmd, cwd=pkg_dir, env=env, stderr=subprocess.STDOUT)
154+
output = subprocess.check_output(
155+
cmd, cwd=pkg_dir, env=env, stderr=subprocess.STDOUT)
153156
return output.decode('utf-8')
154157

155158

156159
def download_and_extract(request, req, target):
157-
cmd = [sys.executable, '-m', 'pip', 'download', '--no-deps',
158-
'--no-binary', ':all:', req]
160+
cmd = [
161+
sys.executable, '-m', 'pip', 'download', '--no-deps',
162+
'--no-binary', ':all:', req,
163+
]
159164
output = subprocess.check_output(cmd, encoding='utf-8')
160165
filename = re.search('Saved (.*)', output).group(1)
161166
request.addfinalizer(functools.partial(os.remove, filename))

0 commit comments

Comments
 (0)