Skip to content

Commit

Permalink
Fix: disable doctest in format_languages() (#10357)
Browse files Browse the repository at this point in the history
The doc tests are cursed:
```
450     Format language data to match Open Library's expected format.451
>>> format_languages(["eng", "fre"])UNEXPECTED EXCEPTION:
AttributeError("'ThreadedDict' object has no attribute 'site'")Traceback
(most recent call last):  File
"/opt/hostedtoolcache/Python/3.12.2/x64/lib/python3.12/doctest.py", line
1361, in __run    exec(compile(example.source, filename, "single",  File
"<doctest openlibrary.catalog.utils.format_languages[0]>", line 1, in
<module>  File
"/home/runner/work/openlibrary/openlibrary/openlibrary/catalog/utils/__init__.py",
line 459, in format_languages    if
web.ctx.site.get(f"/languages/{language.lower()}") is None:
^^^^^^^^^^^^AttributeError: 'ThreadedDict' object has no attribute
'site'
```
  • Loading branch information
scottbarnes authored Jan 18, 2025
1 parent 9357c65 commit 3e18ea8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion openlibrary/catalog/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def __str__(self):
def format_languages(languages: Iterable) -> list[dict[str, str]]:
"""
Format language data to match Open Library's expected format.
>>> format_languages(["eng", "fre"])
For an input of ["eng", "fre"], return:
[{'key': '/languages/eng'}, {'key': '/languages/fre'}]
"""
if not languages:
Expand Down

0 comments on commit 3e18ea8

Please sign in to comment.