File tree 5 files changed +39
-1
lines changed
5 files changed +39
-1
lines changed Original file line number Diff line number Diff line change
1
+ v4.12.0
2
+ =======
3
+
4
+ * py-93259: Now raise ``ValueError `` when ``None `` or an empty
5
+ string are passed to ``Distribution.from_name `` (and other
6
+ callers).
7
+
1
8
v4.11.4
2
9
=======
3
10
Original file line number Diff line number Diff line change 20
20
pattern = r'PEP[- ](?P<pep_number>\d+)' ,
21
21
url = 'https://peps.python.org/pep-{pep_number:0>4}/' ,
22
22
),
23
+ dict (
24
+ pattern = r'(Python #|py-)(?P<python>\d+)' ,
25
+ url = 'https://github.com/python/cpython/issues/{python}' ,
26
+ ),
23
27
],
24
28
)
25
29
}
Original file line number Diff line number Diff line change @@ -548,15 +548,18 @@ def locate_file(self, path):
548
548
"""
549
549
550
550
@classmethod
551
- def from_name (cls , name ):
551
+ def from_name (cls , name : str ):
552
552
"""Return the Distribution for the given package name.
553
553
554
554
:param name: The name of the distribution package to search for.
555
555
:return: The Distribution instance (or subclass thereof) for the named
556
556
package, if found.
557
557
:raises PackageNotFoundError: When the named package's distribution
558
558
metadata cannot be found.
559
+ :raises ValueError: When an invalid value is supplied for name.
559
560
"""
561
+ if not name :
562
+ raise ValueError ("A distribution name is required." )
560
563
try :
561
564
return next (cls .discover (name = name ))
562
565
except StopIteration :
Original file line number Diff line number Diff line change 5
5
import pathlib
6
6
import tempfile
7
7
import textwrap
8
+ import functools
8
9
import contextlib
9
10
10
11
from .py39compat import FS_NONASCII
@@ -294,3 +295,18 @@ def setUp(self):
294
295
# Add self.zip_name to the front of sys.path.
295
296
self .resources = contextlib .ExitStack ()
296
297
self .addCleanup (self .resources .close )
298
+
299
+
300
+ def parameterize (* args_set ):
301
+ """Run test method with a series of parameters."""
302
+
303
+ def wrapper (func ):
304
+ @functools .wraps (func )
305
+ def _inner (self ):
306
+ for args in args_set :
307
+ with self .subTest (** args ):
308
+ func (self , ** args )
309
+
310
+ return _inner
311
+
312
+ return wrapper
Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ def test_new_style_classes(self):
50
50
self .assertIsInstance (Distribution , type )
51
51
self .assertIsInstance (MetadataPathFinder , type )
52
52
53
+ @fixtures .parameterize (
54
+ dict (name = None ),
55
+ dict (name = '' ),
56
+ )
57
+ def test_invalid_inputs_to_from_name (self , name ):
58
+ with self .assertRaises (Exception ):
59
+ Distribution .from_name (name )
60
+
53
61
54
62
class ImportTests (fixtures .DistInfoPkg , unittest .TestCase ):
55
63
def test_import_nonexistent_module (self ):
You can’t perform that action at this time.
0 commit comments