Skip to content

Commit ac8d3e3

Browse files
committed
Address review: harden extras parsing in the metadata tests (#3699)
Use interpolation=None so a stray % in setup.cfg cannot fail these tests for an unrelated reason, and normalize project names per PEP 503 so an underscore or dot spelling compares equal the way pip treats it.
1 parent 236217a commit ac8d3e3

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

xrspatial/tests/test_gpu_extras_metadata.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232

3333
def _extras():
3434
"""Map extra name -> list of requirement strings, comments stripped."""
35-
cfg = configparser.ConfigParser()
35+
# interpolation=None: a stray `%` anywhere in setup.cfg would otherwise
36+
# raise InterpolationSyntaxError and fail these tests for an unrelated
37+
# reason.
38+
cfg = configparser.ConfigParser(interpolation=None)
3639
cfg.read(SETUP_CFG)
3740
out = {}
3841
for name, block in cfg["options.extras_require"].items():
@@ -46,8 +49,13 @@ def _extras():
4649

4750

4851
def _project_name(req):
49-
"""Leading PEP 508 project name of a requirement string."""
50-
return re.split(r"[\s<>=!~;\[]", req, maxsplit=1)[0].lower()
52+
"""Leading project name of a requirement string, PEP 503 normalized.
53+
54+
Normalizing means `cupy_cuda12x` and `cupy.cuda12x` compare equal to
55+
`cupy-cuda12x`, the way pip treats them.
56+
"""
57+
name = re.split(r"[\s<>=!~;\[]", req, maxsplit=1)[0]
58+
return re.sub(r"[-_.]+", "-", name).lower()
5159

5260

5361
def test_no_extra_declares_cuspatial():

0 commit comments

Comments
 (0)