Skip to content

Commit 2977f7c

Browse files
[TESTING] Added doctests as suggested in review (- WIP PR #373 -)
* this work is related to GHI #213 Changes in file docs/utils.py: * added doctests for sanitize_intersphinx_mapping(mapping: dict)
1 parent adc70cc commit 2977f7c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

docs/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,5 +244,22 @@ def sanitize_intersphinx_mapping(mapping: dict) -> dict:
244244
245245
Returns:
246246
dict -- A dictionary with the same structure but with sanitized URLs.
247+
248+
Unit-Testing:
249+
250+
Testcase 1: Basic intersphinx mapping.
251+
252+
>>> mapping = {'python': ('https://docs.python.org/3', None)}
253+
>>> sanitize_intersphinx_mapping(mapping)
254+
{'python': ('https://docs.python.org/3', None)}
255+
256+
Testcase 2: Mapping with URL containing special characters.
257+
258+
>>> mapping = {'project': ('https://github.com/user/project with spaces', None)}
259+
>>> result = sanitize_intersphinx_mapping(mapping)
260+
>>> result['project'][0]
261+
'https://github.com/user/project%20with%20spaces'
262+
>>>
263+
247264
"""
248265
return {key: (sanitize_url(url), extra_value) for key, (url, extra_value) in mapping.items()}

0 commit comments

Comments
 (0)