1212from unittest import mock
1313
1414from pkg_resources import (
15- DistInfoDistribution , Distribution , EggInfoDistribution ,
15+ DistInfoDistribution ,
16+ Distribution ,
17+ EggInfoDistribution ,
1618)
1719
1820import pytest
@@ -82,6 +84,7 @@ def teardown_class(cls):
8284
8385 def test_resource_listdir (self ):
8486 import mod
87+
8588 zp = pkg_resources .ZipProvider (mod )
8689
8790 expected_root = ['data.dat' , 'mod.py' , 'subdir' ]
@@ -95,6 +98,7 @@ def test_resource_listdir(self):
9598 assert zp .resource_listdir ('nonexistent/' ) == []
9699
97100 import mod2
101+
98102 zp2 = pkg_resources .ZipProvider (mod2 )
99103
100104 assert sorted (zp2 .resource_listdir ('' )) == expected_subdir
@@ -110,6 +114,7 @@ def test_resource_filename_rewrites_on_change(self):
110114 subsequent call to get_resource_filename.
111115 """
112116 import mod
117+
113118 manager = pkg_resources .ResourceManager ()
114119 zp = pkg_resources .ZipProvider (mod )
115120 filename = zp .get_resource_filename (manager , 'data.dat' )
@@ -174,10 +179,7 @@ def test_setuptools_not_imported(self):
174179 lines = (
175180 'import pkg_resources' ,
176181 'import sys' ,
177- (
178- 'assert "setuptools" not in sys.modules, '
179- '"setuptools was imported"'
180- ),
182+ ('assert "setuptools" not in sys.modules, ' '"setuptools was imported"' ),
181183 )
182184 cmd = [sys .executable , '-c' , '; ' .join (lines )]
183185 subprocess .check_call (cmd )
@@ -198,7 +200,7 @@ def make_test_distribution(metadata_path, metadata):
198200 with open (metadata_path , 'wb' ) as f :
199201 f .write (metadata )
200202 dists = list (pkg_resources .distributions_from_metadata (dist_dir ))
201- dist , = dists
203+ ( dist ,) = dists
202204
203205 return dist
204206
@@ -244,7 +246,7 @@ def make_distribution_no_version(tmpdir, basename):
244246
245247 dists = list (pkg_resources .distributions_from_metadata (dist_dir ))
246248 assert len (dists ) == 1
247- dist , = dists
249+ ( dist ,) = dists
248250
249251 return dist , dist_dir
250252
@@ -261,16 +263,17 @@ def make_distribution_no_version(tmpdir, basename):
261263 reason = "https://github.com/python/cpython/issues/103632" ,
262264)
263265def test_distribution_version_missing (
264- tmpdir , suffix , expected_filename , expected_dist_type ):
266+ tmpdir , suffix , expected_filename , expected_dist_type
267+ ):
265268 """
266269 Test Distribution.version when the "Version" header is missing.
267270 """
268271 basename = 'foo.{}' .format (suffix )
269272 dist , dist_dir = make_distribution_no_version (tmpdir , basename )
270273
271- expected_text = (
272- "Missing 'Version:' header and/or {} file at path: "
273- ). format ( expected_filename )
274+ expected_text = ("Missing 'Version:' header and/or {} file at path: " ). format (
275+ expected_filename
276+ )
274277 metadata_path = os .path .join (dist_dir , expected_filename )
275278
276279 # Now check the exception raised when the "version" attribute is accessed.
@@ -307,8 +310,7 @@ def test_distribution_version_missing_undetected_path():
307310
308311 msg , dist = excinfo .value .args
309312 expected = (
310- "Missing 'Version:' header and/or PKG-INFO file at path: "
311- '[could not detect]'
313+ "Missing 'Version:' header and/or PKG-INFO file at path: " '[could not detect]'
312314 )
313315 assert msg == expected
314316
@@ -335,10 +337,7 @@ class Environment(str):
335337 env = Environment (tmpdir )
336338 tmpdir .chmod (stat .S_IRWXU )
337339 subs = 'home' , 'lib' , 'scripts' , 'data' , 'egg-base'
338- env .paths = dict (
339- (dirname , str (tmpdir / dirname ))
340- for dirname in subs
341- )
340+ env .paths = dict ((dirname , str (tmpdir / dirname )) for dirname in subs )
342341 list (map (os .mkdir , env .paths .values ()))
343342 return env
344343
@@ -395,8 +394,7 @@ def test_normalize_path_trailing_sep(self, unnormalized, normalized):
395394 ],
396395 )
397396 def test_normalize_path_normcase (self , unnormalized , normalized ):
398- """Ensure mixed case is normalized on case-insensitive filesystems.
399- """
397+ """Ensure mixed case is normalized on case-insensitive filesystems."""
400398 result_from_unnormalized = pkg_resources .normalize_path (unnormalized )
401399 result_from_normalized = pkg_resources .normalize_path (normalized )
402400 assert result_from_unnormalized == result_from_normalized
@@ -414,7 +412,6 @@ def test_normalize_path_normcase(self, unnormalized, normalized):
414412 ],
415413 )
416414 def test_normalize_path_backslash_sep (self , unnormalized , expected ):
417- """Ensure path seps are cleaned on backslash path sep systems.
418- """
415+ """Ensure path seps are cleaned on backslash path sep systems."""
419416 result = pkg_resources .normalize_path (unnormalized )
420417 assert result .endswith (expected )
0 commit comments