diff --git a/.copier-answers.yml b/.copier-answers.yml index f990ec6..4b717f9 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -2,7 +2,7 @@ # Answer file maintained by Copier for: https://github.com/KyleKing/mdformat-plugin-template # DO NOT MODIFY THIS FILE. Edit by re-running copier and changing responses to the questions # Check into version control. -_commit: 0.1.2 +_commit: 0.1.3 _src_path: gh:KyleKing/mdformat-plugin-template author_email: dev.act.kyle@gmail.com author_name: Kyle King diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c513a24..3c03568 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.12 - - uses: pre-commit/action@v3 + - uses: pre-commit/action@v3.0.1 tests: runs-on: ${{ matrix.os }} strategy: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d705910..78e5c4b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -73,6 +73,6 @@ export eval $(envchain FLIT env | grep FLIT_PASSWORD=) flit publish ``` -or trigger the GitHub Action job, by creating a release with a tag equal to the version, e.g. `v0.0.1` and updating the version in `mdformat_admon/__init__.py`. +or trigger the GitHub Action job, by creating a release with a tag equal to the version, e.g. `v0.0.1` and updating the version in `mdformat_gfm_alerts/__init__.py`. Note, this requires generating an API key on PyPi and adding it to the repository `Settings/Secrets`, under the name `PYPI_KEY`. diff --git a/pyproject.toml b/pyproject.toml index 1feae86..49b9db6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,6 +29,7 @@ gfm_alerts = "mdformat_gfm_alerts" dev = ["pre-commit"] test = [ "pytest >= 7.4.4", + "pytest-beartype >= 0.0.2", "pytest-cov >= 4.1.0", ] @@ -44,7 +45,7 @@ ignore_patterns = [] now = true patterns = ["*.md", "*.py"] runner = "tox" -runner_args = ["-e", "py38"] +runner_args = ["-e", "py38-beartype"] [tool.tomlsort] all = true diff --git a/tests/helpers.py b/tests/helpers.py index 3197c8b..c04386c 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,21 +1,32 @@ """Test Helpers.""" +from __future__ import annotations + +import re + _SHOW_TEXT = True # PLANNED: Make configurable based on pytest CLI -def _print(content: str, show_whitespace: bool) -> None: - if show_whitespace: - raise NotImplementedError("To use, port logic from `mdformat_mkdocs`") +def separate_indent(line: str) -> tuple[str, str]: + """Separate leading indent from content. Also used by the test suite.""" + re_indent = re.compile(r"(?P\s*)(?P[^\s]?.*)") + match = re_indent.match(line) + assert match is not None # for pyright + return (match["indent"], match["content"]) + +def _print(content: str, show_whitespace: bool) -> None: for line in content.split("\n"): - print(line) + indent, content = separate_indent(line) + visible_indents = indent.replace(" ", "→").replace("\t", "➤") + print((visible_indents if show_whitespace else indent) + content) def print_text(output: str, expected: str, show_whitespace: bool = False) -> None: """Conditionall print text for debugging.""" if _SHOW_TEXT: print("-- Output --") - _print(output.strip(), show_whitespace) + _print(output, show_whitespace) print("-- Expected --") - _print(expected.strip(), show_whitespace) + _print(expected, show_whitespace) print("-- --") diff --git a/tox.ini b/tox.ini index 56fe852..a1e7772 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{38} + py{38}-beartype py{312}-cov py{312}-pre-commit py{38}-hook @@ -9,9 +9,9 @@ envlist = isolated_build = True skip_missing_interpreters = False -[testenv:py{38}] +[testenv:py{38}-beartype] extras = test -commands = pytest {posargs} --ff --nf -vv +commands = pytest {posargs} --ff --nf -vv --exitfirst --beartype-packages='mdformat_gfm_alerts' [testenv:py{312}-cov] extras = test