Skip to content

Commit 38429c9

Browse files
committed
Add empty expression test case
1 parent 4ab2335 commit 38429c9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

flit_core/flit_core/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def normalise_compound_license_expr(s: str) -> str:
833833
Spec: https://spdx.github.io/spdx-spec/v2.2.2/SPDX-license-expressions/
834834
"""
835835
invalid_msg = "'{s}' is not a valid SPDX license expression: {reason}"
836-
if s == '':
836+
if not s or s.isspace():
837837
raise ConfigError(f"The SPDX license expression must not be empty")
838838

839839
stack = 0

flit_core/tests_core/test_config.py

+18
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,24 @@ def test_license_expr_error(invalid_expr: str):
327327
config.read_pep621_metadata(proj, samples_dir / 'pep621' / 'pyproject.toml')
328328

329329

330+
@pytest.mark.parametrize('invalid_expr', [
331+
"",
332+
" ",
333+
"\t",
334+
"\r",
335+
"\n",
336+
"\f",
337+
" \t \n \r \f ",
338+
])
339+
def test_license_expr_error_empty(invalid_expr: str):
340+
proj = {
341+
'name': 'module1', 'version': '1.0', 'description': 'x',
342+
'license': invalid_expr,
343+
}
344+
with pytest.raises(config.ConfigError, match="must not be empty"):
345+
config.read_pep621_metadata(proj, samples_dir / 'pep621' / 'pyproject.toml')
346+
347+
330348
@pytest.mark.parametrize('invalid_expr', [
331349
"mit or mit",
332350
"or",

0 commit comments

Comments
 (0)