mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-10 07:57:58 +08:00
refactor(tests): modernize test_readme_parser to use pathlib.Path
Replace os.path.join + manual open() with Path(__file__).resolve().parents[2] and Path.read_text() for locating and reading README.md. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
"""Tests for the readme_parser module."""
|
"""Tests for the readme_parser module."""
|
||||||
|
|
||||||
import os
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -437,9 +437,8 @@ class TestParseSectionEntries:
|
|||||||
class TestParseRealReadme:
|
class TestParseRealReadme:
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def load_readme(self):
|
def load_readme(self):
|
||||||
readme_path = os.path.join(os.path.dirname(__file__), "..", "..", "README.md")
|
readme_path = Path(__file__).resolve().parents[2] / "README.md"
|
||||||
with open(readme_path, encoding="utf-8") as f:
|
self.readme_text = readme_path.read_text(encoding="utf-8")
|
||||||
self.readme_text = f.read()
|
|
||||||
self.groups = parse_readme(self.readme_text)
|
self.groups = parse_readme(self.readme_text)
|
||||||
self.cats = [c for g in self.groups for c in g["categories"]]
|
self.cats = [c for g in self.groups for c in g["categories"]]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user