File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed
Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,27 @@ def test_unknown_version():
2929 _deprecate .deprecate ("Old thing" , 12345 , "new thing" )
3030
3131
32+ @pytest .mark .parametrize (
33+ "deprecated, plural, expected" ,
34+ [
35+ (
36+ "Old thing" ,
37+ False ,
38+ r"Old thing is deprecated and should be removed\." ,
39+ ),
40+ (
41+ "Old things" ,
42+ True ,
43+ r"Old things are deprecated and should be removed\." ,
44+ ),
45+ ],
46+ )
47+ def test_old_version (deprecated , plural , expected ):
48+ expected = r""
49+ with pytest .raises (RuntimeError , match = expected ):
50+ _deprecate .deprecate (deprecated , 1 , plural = plural )
51+
52+
3253def test_plural ():
3354 expected = (
3455 r"Old things are deprecated and will be removed in Pillow 10 \(2023-07-01\)\. "
Original file line number Diff line number Diff line change 22
33import warnings
44
5+ from . import __version__
6+
57
68def deprecate (
79 deprecated : str ,
@@ -38,10 +40,12 @@ def deprecate(
3840
3941 is_ = "are" if plural else "is"
4042
41- if when == 10 :
42- removed = "Pillow 10 (2023-07-01)"
43- elif when is None :
43+ if when is None :
4444 removed = "a future version"
45+ elif when <= int (__version__ .split ("." )[0 ]):
46+ raise RuntimeError (f"{ deprecated } { is_ } deprecated and should be removed." )
47+ elif when == 10 :
48+ removed = "Pillow 10 (2023-07-01)"
4549 else :
4650 raise ValueError (f"Unknown removal version, update { __name__ } ?" )
4751
You can’t perform that action at this time.
0 commit comments