@@ -293,6 +293,54 @@ def test_invalid_module_name_relaxed(example):
293293 assert formats .python_module_name_relaxed (example ) is False
294294
295295
296+ @pytest .mark .parametrize (
297+ "example" ,
298+ [
299+ "MIT" ,
300+ "Bsd-3-clause" ,
301+ "mit and (apache-2.0 or bsd-2-clause)" ,
302+ "MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)" ,
303+ "GPL-3.0-only WITH Classpath-exception-2.0 OR BSD-3-Clause" ,
304+ "LicenseRef-Special-License OR CC0-1.0 OR Unlicense" ,
305+ "LicenseRef-Public-Domain" ,
306+ "licenseref-proprietary" ,
307+ "LicenseRef-Beerware-4.2" ,
308+ "(LicenseRef-Special-License OR LicenseRef-OtherLicense) OR Unlicense" ,
309+ ],
310+ )
311+ def test_valid_pep639_license_expression (example ):
312+ assert formats .SPDX (example ) is True
313+
314+
315+ @pytest .mark .parametrize (
316+ "example" ,
317+ [
318+ "" ,
319+ "Use-it-after-midnight" ,
320+ "LicenseRef-License with spaces" ,
321+ "LicenseRef-License_with_underscores" ,
322+ "or" ,
323+ "and" ,
324+ "with" ,
325+ "mit or" ,
326+ "mit and" ,
327+ "mit with" ,
328+ "or mit" ,
329+ "and mit" ,
330+ "with mit" ,
331+ "(mit" ,
332+ "mit)" ,
333+ "mit or or apache-2.0" ,
334+ # Missing an operator before `(`.
335+ "mit or apache-2.0 (bsd-3-clause and MPL-2.0)" ,
336+ # "2-BSD-Clause is not a valid license.
337+ "Apache-2.0 OR 2-BSD-Clause" ,
338+ ],
339+ )
340+ def test_invalid_pep639_license_expression (example ):
341+ assert formats .SPDX (example ) is False
342+
343+
296344class TestClassifiers :
297345 """The ``_TroveClassifier`` class and ``_download_classifiers`` are part of the
298346 private API and therefore need to be tested.
0 commit comments