mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-09 11:13:01 +08:00
test(website): remove redundant and brittle tests
Drops tests that either duplicate coverage already provided by adjacent cases (single-word slugify, trailing-slash checks) or hard-code first- category names and specific description strings that break whenever the README content shifts. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -68,18 +68,9 @@ class TestSlugify:
|
|||||||
def test_uppercase_acronym(self):
|
def test_uppercase_acronym(self):
|
||||||
assert slugify("RESTful API") == "restful-api"
|
assert slugify("RESTful API") == "restful-api"
|
||||||
|
|
||||||
def test_all_caps(self):
|
|
||||||
assert slugify("CMS") == "cms"
|
|
||||||
|
|
||||||
def test_hyphenated_input(self):
|
def test_hyphenated_input(self):
|
||||||
assert slugify("Command-line Tools") == "command-line-tools"
|
assert slugify("Command-line Tools") == "command-line-tools"
|
||||||
|
|
||||||
def test_special_chars(self):
|
|
||||||
assert slugify("Editor Plugins and IDEs") == "editor-plugins-and-ides"
|
|
||||||
|
|
||||||
def test_single_word(self):
|
|
||||||
assert slugify("Audio") == "audio"
|
|
||||||
|
|
||||||
def test_extra_spaces(self):
|
def test_extra_spaces(self):
|
||||||
assert slugify(" Date and Time ") == "date-and-time"
|
assert slugify(" Date and Time ") == "date-and-time"
|
||||||
|
|
||||||
@@ -88,9 +79,6 @@ class TestSubcategoryPath:
|
|||||||
def test_builds_path(self):
|
def test_builds_path(self):
|
||||||
assert subcategory_path("web-frameworks", "synchronous") == "/categories/web-frameworks/synchronous/"
|
assert subcategory_path("web-frameworks", "synchronous") == "/categories/web-frameworks/synchronous/"
|
||||||
|
|
||||||
def test_trailing_slash(self):
|
|
||||||
assert subcategory_path("a", "b").endswith("/")
|
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# build (integration)
|
# build (integration)
|
||||||
@@ -383,59 +371,6 @@ class TestBuild:
|
|||||||
|
|
||||||
assert not (tmp_path / "website" / "output" / "categories" / "stale").exists()
|
assert not (tmp_path / "website" / "output" / "categories" / "stale").exists()
|
||||||
|
|
||||||
def test_index_contains_category_names(self, tmp_path):
|
|
||||||
readme = textwrap.dedent("""\
|
|
||||||
# T
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Group A**
|
|
||||||
|
|
||||||
## Alpha
|
|
||||||
|
|
||||||
- [a](https://x.com) - A.
|
|
||||||
|
|
||||||
**Group B**
|
|
||||||
|
|
||||||
## Beta
|
|
||||||
|
|
||||||
- [b](https://x.com) - B.
|
|
||||||
|
|
||||||
# Contributing
|
|
||||||
|
|
||||||
Done.
|
|
||||||
""")
|
|
||||||
self._make_repo(tmp_path, readme)
|
|
||||||
build(tmp_path)
|
|
||||||
|
|
||||||
index_html = (tmp_path / "website" / "output" / "index.html").read_text()
|
|
||||||
assert "Alpha" in index_html
|
|
||||||
assert "Beta" in index_html
|
|
||||||
assert "Group A" in index_html
|
|
||||||
assert "Group B" in index_html
|
|
||||||
|
|
||||||
def test_index_contains_preview_text(self, tmp_path):
|
|
||||||
readme = textwrap.dedent("""\
|
|
||||||
# T
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Stuff
|
|
||||||
|
|
||||||
- [django](https://x.com) - A framework.
|
|
||||||
- [flask](https://x.com) - A micro.
|
|
||||||
|
|
||||||
# Contributing
|
|
||||||
|
|
||||||
Done.
|
|
||||||
""")
|
|
||||||
self._make_repo(tmp_path, readme)
|
|
||||||
build(tmp_path)
|
|
||||||
|
|
||||||
index_html = (tmp_path / "website" / "output" / "index.html").read_text()
|
|
||||||
assert "django" in index_html
|
|
||||||
assert "flask" in index_html
|
|
||||||
|
|
||||||
def test_build_with_stars_sorts_by_stars(self, tmp_path):
|
def test_build_with_stars_sorts_by_stars(self, tmp_path):
|
||||||
readme = textwrap.dedent("""\
|
readme = textwrap.dedent("""\
|
||||||
# T
|
# T
|
||||||
|
|||||||
@@ -24,29 +24,6 @@ class TestExtractGithubRepos:
|
|||||||
result = extract_github_repos(readme)
|
result = extract_github_repos(readme)
|
||||||
assert result == {"psf/requests", "pallets/flask"}
|
assert result == {"psf/requests", "pallets/flask"}
|
||||||
|
|
||||||
def test_ignores_non_github_urls(self):
|
|
||||||
readme = "* [pypy](https://foss.heptapod.net/pypy/pypy) - Fast Python."
|
|
||||||
result = extract_github_repos(readme)
|
|
||||||
assert result == set()
|
|
||||||
|
|
||||||
def test_ignores_github_io_urls(self):
|
|
||||||
readme = "* [docs](https://user.github.io/project) - Docs site."
|
|
||||||
result = extract_github_repos(readme)
|
|
||||||
assert result == set()
|
|
||||||
|
|
||||||
def test_ignores_github_wiki_and_blob_urls(self):
|
|
||||||
readme = (
|
|
||||||
"* [wiki](https://github.com/org/repo/wiki) - Wiki.\n"
|
|
||||||
"* [file](https://github.com/org/repo/blob/main/f.py) - File."
|
|
||||||
)
|
|
||||||
result = extract_github_repos(readme)
|
|
||||||
assert result == set()
|
|
||||||
|
|
||||||
def test_handles_trailing_slash(self):
|
|
||||||
readme = "* [lib](https://github.com/org/repo/) - Lib."
|
|
||||||
result = extract_github_repos(readme)
|
|
||||||
assert result == {"org/repo"}
|
|
||||||
|
|
||||||
def test_deduplicates(self):
|
def test_deduplicates(self):
|
||||||
readme = (
|
readme = (
|
||||||
"* [a](https://github.com/org/repo) - A.\n"
|
"* [a](https://github.com/org/repo) - A.\n"
|
||||||
|
|||||||
@@ -449,9 +449,6 @@ class TestParseRealReadme:
|
|||||||
def test_at_least_11_groups(self):
|
def test_at_least_11_groups(self):
|
||||||
assert len(self.groups) >= 11
|
assert len(self.groups) >= 11
|
||||||
|
|
||||||
def test_first_group_is_ai_ml(self):
|
|
||||||
assert self.groups[0]["name"] == "AI & ML"
|
|
||||||
|
|
||||||
def test_at_least_69_categories(self):
|
def test_at_least_69_categories(self):
|
||||||
assert len(self.cats) >= 69
|
assert len(self.cats) >= 69
|
||||||
|
|
||||||
@@ -459,39 +456,10 @@ class TestParseRealReadme:
|
|||||||
all_names = [c["name"] for c in self.cats]
|
all_names = [c["name"] for c in self.cats]
|
||||||
assert "Contributing" not in all_names
|
assert "Contributing" not in all_names
|
||||||
|
|
||||||
def test_first_category_is_ai_and_agents(self):
|
|
||||||
assert self.cats[0]["name"] == "AI and Agents"
|
|
||||||
assert self.cats[0]["slug"] == "ai-and-agents"
|
|
||||||
|
|
||||||
def test_web_apis_slug(self):
|
|
||||||
slugs = [c["slug"] for c in self.cats]
|
|
||||||
assert "web-apis" in slugs
|
|
||||||
|
|
||||||
def test_descriptions_extracted(self):
|
|
||||||
ai = next(c for c in self.cats if c["name"] == "AI and Agents")
|
|
||||||
assert "AI applications" in ai["description"]
|
|
||||||
|
|
||||||
def test_entry_counts_nonzero(self):
|
def test_entry_counts_nonzero(self):
|
||||||
for cat in self.cats:
|
for cat in self.cats:
|
||||||
assert cat["entry_count"] > 0, f"{cat['name']} has 0 entries"
|
assert cat["entry_count"] > 0, f"{cat['name']} has 0 entries"
|
||||||
|
|
||||||
def test_async_has_also_see(self):
|
|
||||||
async_cat = next(c for c in self.cats if c["name"] == "Asynchronous Programming")
|
|
||||||
asyncio_entry = next(e for e in async_cat["entries"] if e["name"] == "asyncio")
|
|
||||||
assert len(asyncio_entry["also_see"]) >= 1
|
|
||||||
assert asyncio_entry["also_see"][0]["name"] == "awesome-asyncio"
|
|
||||||
|
|
||||||
def test_description_links_stripped_to_text(self):
|
|
||||||
algos = next(c for c in self.cats if c["name"] == "Algorithms and Design Patterns")
|
|
||||||
assert "awesome-algorithms" in algos["description"]
|
|
||||||
assert "https://" not in algos["description"]
|
|
||||||
assert 'href="https://github.com/tayllan/awesome-algorithms"' in algos["description_html"]
|
|
||||||
|
|
||||||
def test_miscellaneous_category_in_other_group(self):
|
|
||||||
other_group = next((g for g in self.groups if g["name"] == "Other"), None)
|
|
||||||
assert other_group is not None
|
|
||||||
assert any(c["name"] == "Miscellaneous" for c in other_group["categories"])
|
|
||||||
|
|
||||||
def test_all_entries_have_nonempty_names(self):
|
def test_all_entries_have_nonempty_names(self):
|
||||||
bad = []
|
bad = []
|
||||||
for cat in self.cats:
|
for cat in self.cats:
|
||||||
|
|||||||
Reference in New Issue
Block a user