|
7 | 7 | import io |
8 | 8 | import json |
9 | 9 | import os |
| 10 | +import re |
10 | 11 | import subprocess |
11 | 12 | import sys |
12 | 13 |
|
@@ -315,3 +316,44 @@ def test_lsp_completes_module_members(): |
315 | 316 | labels = [item["label"] for item in completion["result"]["items"]] |
316 | 317 | assert "sqrt" in labels |
317 | 318 | assert "median" in labels |
| 319 | + |
| 320 | + |
| 321 | +# --- packaging metadata ----------------------------------------------------- |
| 322 | + |
| 323 | +REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) |
| 324 | +FUNDING = "https://buymeacoffee.com/piyushmishra00" |
| 325 | + |
| 326 | + |
| 327 | +def read(*parts): |
| 328 | + with open(os.path.join(REPO, *parts), encoding="utf-8") as handle: |
| 329 | + return handle.read() |
| 330 | + |
| 331 | + |
| 332 | +def test_the_funding_link_is_the_same_everywhere(): |
| 333 | + """A wrong handle shipped to PyPI once, where releases are immutable and the |
| 334 | + only fix is a new version. Every copy of the link is checked here now.""" |
| 335 | + wrong = [] |
| 336 | + for name in ("README.md", "pyproject.toml", "CONTRIBUTING.md", |
| 337 | + "docs/README.md", ".github/FUNDING.yml", ".github/release-notes.md", |
| 338 | + "site/index.html", "site/docs.html", "site/playground.html"): |
| 339 | + text = read(*name.split("/")) |
| 340 | + for found in re.findall(r"https://buymeacoffee\.com/[A-Za-z0-9_-]+", text): |
| 341 | + if found != FUNDING: |
| 342 | + wrong.append(f"{name}: {found}") |
| 343 | + assert not wrong, "these point at the wrong Buy Me a Coffee handle: " + "; ".join(wrong) |
| 344 | + |
| 345 | + |
| 346 | +def test_the_readme_pypi_will_show_has_a_working_funding_link(): |
| 347 | + """pyproject points long_description at README.md, so this is the text that |
| 348 | + ends up on the PyPI project page.""" |
| 349 | + readme = read("README.md") |
| 350 | + assert FUNDING in readme |
| 351 | + assert 'readme = "README.md"' in read("pyproject.toml") |
| 352 | + |
| 353 | + |
| 354 | +def test_the_version_is_the_same_everywhere(): |
| 355 | + import she |
| 356 | + version = she.__version__ |
| 357 | + assert f'version = "{version}"' in read("pyproject.toml") |
| 358 | + assert f'version = "{version}"' in read("she.toml") |
| 359 | + assert f'"version": "{version}"' in read("editors", "vscode", "package.json") |
0 commit comments