Skip to content

Commit

Permalink
Tests: add package description metadata retrieval for Python 3.9 and …
Browse files Browse the repository at this point in the history
…earlier (#1218)
  • Loading branch information
jayaddison authored Aug 15, 2024
1 parent 1a48642 commit 461e9b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-e .
coverage>=7.4.4
types-beautifulsoup4>=4.12.0
importlib-metadata>=4.6 ; python_version < "3.10"
17 changes: 9 additions & 8 deletions tests/library/test_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
import sys
import unittest
from collections import defaultdict
from importlib.metadata import PackageNotFoundError, metadata

if sys.version_info >= (3, 10):
from importlib.metadata import PackageNotFoundError, metadata
else:
# TODO: Remove this branch once py3.10 is our minimum baseline;
# package description metadata (that we rely on for 'test_includes') is
# only available in importlib.metadata from py3.10 onwards
from importlib_metadata import PackageNotFoundError, metadata

from typing import Dict, List, Optional, Tuple

from recipe_scrapers import SCRAPERS, AbstractScraper
Expand Down Expand Up @@ -121,13 +129,6 @@ def test_includes(self):
scraper_index = get_scraper_index()
primary_domains = sorted(scraper_index.keys())

# TODO: Remove this skip-branch once py3.10 is our minimum baseline;
# package description metadata (that we rely on for this test) is only
# available in importlib.metadata from py3.10 onwards
if sys.version_info < (3, 10):
msg = "Python 3.10+ is required for importlib.metadata to read package 'description' metadata."
self.skipTest(msg)

try:
lines = get_list_lines()
except PackageNotFoundError:
Expand Down

0 comments on commit 461e9b7

Please sign in to comment.