pytest-markdown-docs 0.5.1__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. pytest_markdown_docs-0.7.0/.github/pull_request_template.md +5 -0
  2. pytest_markdown_docs-0.7.0/.github/workflows/check.yml +27 -0
  3. pytest_markdown_docs-0.7.0/.github/workflows/ci.yml +31 -0
  4. pytest_markdown_docs-0.7.0/.github/workflows/codeql.yml +74 -0
  5. pytest_markdown_docs-0.7.0/.gitignore +129 -0
  6. pytest_markdown_docs-0.7.0/.pre-commit-config.yaml +8 -0
  7. pytest_markdown_docs-0.7.0/Makefile +8 -0
  8. pytest_markdown_docs-0.5.1/README.md → pytest_markdown_docs-0.7.0/PKG-INFO +46 -1
  9. pytest_markdown_docs-0.5.1/PKG-INFO → pytest_markdown_docs-0.7.0/README.md +33 -21
  10. pytest_markdown_docs-0.7.0/pyproject.toml +32 -0
  11. pytest_markdown_docs-0.7.0/pytest-markdown-docs.iml +13 -0
  12. pytest_markdown_docs-0.7.0/src/pytest_markdown_docs/plugin.py +402 -0
  13. pytest_markdown_docs-0.7.0/src/pytest_markdown_docs/py.typed +0 -0
  14. pytest_markdown_docs-0.7.0/tests/conftest.py +10 -0
  15. pytest_markdown_docs-0.7.0/tests/plugin_test.py +433 -0
  16. pytest_markdown_docs-0.7.0/tests/support/docstring_error_after.py +11 -0
  17. pytest_markdown_docs-0.7.0/tests/support/docstring_error_before.py +11 -0
  18. pytest_markdown_docs-0.7.0/uv.lock +356 -0
  19. pytest_markdown_docs-0.5.1/pyproject.toml +0 -32
  20. pytest_markdown_docs-0.5.1/src/pytest_markdown_docs/plugin.py +0 -278
  21. {pytest_markdown_docs-0.5.1 → pytest_markdown_docs-0.7.0}/LICENSE +0 -0
  22. {pytest_markdown_docs-0.5.1 → pytest_markdown_docs-0.7.0}/src/pytest_markdown_docs/__init__.py +0 -0
  23. {pytest_markdown_docs-0.5.1 → pytest_markdown_docs-0.7.0}/src/pytest_markdown_docs/hooks.py +0 -0
@@ -0,0 +1,5 @@
1
+ <!--
2
+ ✍️ Write a short summary of this change, then request review from a recent contributor.
3
+ -->
4
+
5
+ **Issue:** https://github.com/modal-labs/pytest-markdown-docs/issues/XX or N/A
@@ -0,0 +1,27 @@
1
+ name: ruff & mypy
2
+ on: push
3
+
4
+ jobs:
5
+ build:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v3
9
+ - name: Install uv
10
+ uses: astral-sh/setup-uv@v3
11
+
12
+ - name: Install Python (3.11)
13
+ uses: actions/setup-python@v5
14
+ with:
15
+ python-version: 3.11
16
+
17
+ - name: Install the project
18
+ run: uv sync --all-extras --dev --no-install-project
19
+
20
+ - name: Ruff check
21
+ run: uv run ruff check --diff
22
+
23
+ - name: Ruff format
24
+ run: uv run ruff format --diff
25
+
26
+ - name: Mypy
27
+ run: uv run mypy .
@@ -0,0 +1,31 @@
1
+ name: Test
2
+ on: push
3
+
4
+ jobs:
5
+ build:
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - name: Install uv
14
+ uses: astral-sh/setup-uv@v3
15
+
16
+ - name: Install Python ${{ matrix.python-version }}
17
+ uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+
21
+ - name: Install the project
22
+ run: uv sync --all-extras --dev
23
+
24
+ - name: Run tests with pytest
25
+ run: uv run pytest
26
+
27
+ - name: Downgrade to pytest 7
28
+ run: uv pip install "pytest<8"
29
+
30
+ - name: Run tests with pytest 7
31
+ run: uv run pytest
@@ -0,0 +1,74 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ "main" ]
17
+ pull_request:
18
+ schedule:
19
+ - cron: '42 12 * * 0'
20
+
21
+ jobs:
22
+ analyze:
23
+ name: Analyze
24
+ runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
25
+ permissions:
26
+ actions: read
27
+ contents: read
28
+ security-events: write
29
+
30
+ strategy:
31
+ fail-fast: false
32
+ matrix:
33
+ language: [ 'python' ]
34
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
35
+ # Use only 'java' to analyze code written in Java, Kotlin or both
36
+ # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
37
+ # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v3
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v2
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+
52
+ # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53
+ # queries: security-extended,security-and-quality
54
+
55
+
56
+ # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
57
+ # If this step fails, then you should remove it and run the build manually (see below)
58
+ - name: Autobuild
59
+ uses: github/codeql-action/autobuild@v2
60
+
61
+ # ℹ️ Command-line programs to run using the OS shell.
62
+ # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63
+
64
+ # If the Autobuild fails above, remove it and uncomment the following three lines.
65
+ # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66
+
67
+ # - run: |
68
+ # echo "Run, Build Application using script"
69
+ # ./location_of_script_within_repo/buildscript.sh
70
+
71
+ - name: Perform CodeQL Analysis
72
+ uses: github/codeql-action/analyze@v2
73
+ with:
74
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1,129 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ *.py,cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
90
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
91
+ # install all needed dependencies.
92
+ #Pipfile.lock
93
+
94
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95
+ __pypackages__/
96
+
97
+ # Celery stuff
98
+ celerybeat-schedule
99
+ celerybeat.pid
100
+
101
+ # SageMath parsed files
102
+ *.sage.py
103
+
104
+ # Environments
105
+ .env
106
+ .venv
107
+ env/
108
+ venv/
109
+ ENV/
110
+ env.bak/
111
+ venv.bak/
112
+
113
+ # Spyder project settings
114
+ .spyderproject
115
+ .spyproject
116
+
117
+ # Rope project settings
118
+ .ropeproject
119
+
120
+ # mkdocs documentation
121
+ /site
122
+
123
+ # mypy
124
+ .mypy_cache/
125
+ .dmypy.json
126
+ dmypy.json
127
+
128
+ # Pyre type checker
129
+ .pyre/
@@ -0,0 +1,8 @@
1
+ repos:
2
+ - repo: https://github.com/charliermarsh/ruff-pre-commit
3
+ rev: "v0.2.1"
4
+ hooks:
5
+ - id: ruff
6
+ # Autofix, and respect `exclude` and `extend-exclude` settings.
7
+ args: [--fix, --exit-non-zero-on-fix]
8
+ - id: ruff-format
@@ -0,0 +1,8 @@
1
+ build:
2
+ uv build
3
+
4
+ clean:
5
+ rm -rf dist
6
+
7
+ publish: clean build
8
+ uv publish
@@ -1,3 +1,15 @@
1
+ Metadata-Version: 2.3
2
+ Name: pytest-markdown-docs
3
+ Version: 0.7.0
4
+ Summary: Run markdown code fences through pytest
5
+ Author: Modal Labs
6
+ Author-email: Elias Freider <elias@modal.com>
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Requires-Dist: markdown-it-py<4.0,>=2.2.0
10
+ Requires-Dist: pytest>=7.0.0
11
+ Description-Content-Type: text/markdown
12
+
1
13
  # Pytest Markdown Docs
2
14
 
3
15
  A plugin for [pytest](https://docs.pytest.org) that uses markdown code snippets from markdown files and docstrings as tests.
@@ -136,6 +148,39 @@ assert a + " world" == "hello world"
136
148
  ```
137
149
  ````
138
150
 
151
+ ### Compatibility with Material for MkDocs
152
+
153
+ Material for Mkdocs is not compatible with the default syntax.
154
+
155
+ But if the extension `pymdownx.superfences` is configured for mkdocs, the brace format can be used:
156
+ ````markdown
157
+ ```{.python continuation}
158
+ ````
159
+
160
+ You will need to call pytest with the `--markdown-docs-syntax` option:
161
+ ```shell
162
+ pytest --markdown-docs --markdown-docs-syntax=superfences
163
+ ```
164
+
165
+ ## MDX Comments for Metadata Options
166
+ In .mdx files, you can use MDX comments to provide additional options for code blocks. These comments should be placed immediately before the code block and take the following form:
167
+
168
+ ```mdx
169
+ {/* pmd-metadata: notest fixture:capsys */}
170
+ ```python
171
+ print("hello")
172
+ captured = capsys.readouterr()
173
+ assert captured.out == "hello\n"
174
+ ```
175
+
176
+ The following options can be specified using MDX comments:
177
+
178
+ * notest: Exclude the code block from testing.
179
+ * fixture:<name>: Apply named pytest fixtures to the code block.
180
+ * continuation: Continue from the previous code block, allowing you to carry over state.
181
+
182
+ This approach allows you to add metadata to the code block without modifying the code fence itself, making it particularly useful in MDX environments.
183
+
139
184
  ## Testing of this plugin
140
185
 
141
186
  You can test this module itself (sadly not using markdown tests at the moment) using pytest:
@@ -156,4 +201,4 @@ Or for fun, you can use this plugin to include testing of the validity of snippe
156
201
  * Line numbers are "wrong" for docstring-inlined snippets (since we don't know where in the file the docstring starts)
157
202
  * Line numbers are "wrong" for continuation blocks even in pure markdown files (can be worked out with some refactoring)
158
203
  * There are probably more appropriate ways to use pytest internal APIs to get more features "for free" - current state of the code is a bit "patch it til' it works".
159
- * Assertions are not rewritten w/ pretty data structure inspection like they are with regular pytest tests by default
204
+ * Assertions are not rewritten w/ pretty data structure inspection like they are with regular pytest tests by default
@@ -1,24 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: pytest-markdown-docs
3
- Version: 0.5.1
4
- Summary: Run markdown code fences through pytest
5
- Home-page: https://github.com/modal-com/pytest-markdown-docs
6
- License: MIT
7
- Author: Modal Labs
8
- Requires-Python: >=3.8,<4.0
9
- Classifier: Framework :: Pytest
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Classifier: Programming Language :: Python :: 3.10
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
- Requires-Dist: markdown-it-py (>=2.2.0,<4.0)
18
- Requires-Dist: pytest (>=7.0.0)
19
- Project-URL: Repository, https://github.com/modal-com/pytest-markdown-docs
20
- Description-Content-Type: text/markdown
21
-
22
1
  # Pytest Markdown Docs
23
2
 
24
3
  A plugin for [pytest](https://docs.pytest.org) that uses markdown code snippets from markdown files and docstrings as tests.
@@ -157,6 +136,39 @@ assert a + " world" == "hello world"
157
136
  ```
158
137
  ````
159
138
 
139
+ ### Compatibility with Material for MkDocs
140
+
141
+ Material for Mkdocs is not compatible with the default syntax.
142
+
143
+ But if the extension `pymdownx.superfences` is configured for mkdocs, the brace format can be used:
144
+ ````markdown
145
+ ```{.python continuation}
146
+ ````
147
+
148
+ You will need to call pytest with the `--markdown-docs-syntax` option:
149
+ ```shell
150
+ pytest --markdown-docs --markdown-docs-syntax=superfences
151
+ ```
152
+
153
+ ## MDX Comments for Metadata Options
154
+ In .mdx files, you can use MDX comments to provide additional options for code blocks. These comments should be placed immediately before the code block and take the following form:
155
+
156
+ ```mdx
157
+ {/* pmd-metadata: notest fixture:capsys */}
158
+ ```python
159
+ print("hello")
160
+ captured = capsys.readouterr()
161
+ assert captured.out == "hello\n"
162
+ ```
163
+
164
+ The following options can be specified using MDX comments:
165
+
166
+ * notest: Exclude the code block from testing.
167
+ * fixture:<name>: Apply named pytest fixtures to the code block.
168
+ * continuation: Continue from the previous code block, allowing you to carry over state.
169
+
170
+ This approach allows you to add metadata to the code block without modifying the code fence itself, making it particularly useful in MDX environments.
171
+
160
172
  ## Testing of this plugin
161
173
 
162
174
  You can test this module itself (sadly not using markdown tests at the moment) using pytest:
@@ -0,0 +1,32 @@
1
+ [project]
2
+ name = "pytest-markdown-docs"
3
+ version = "0.7.0"
4
+ description = "Run markdown code fences through pytest"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Modal Labs"},
8
+ { name = "Elias Freider", email = "elias@modal.com" }
9
+ ]
10
+ license = "MIT"
11
+ requires-python = ">=3.8"
12
+ dependencies = [
13
+ "markdown-it-py>=2.2.0,<4.0",
14
+ "pytest>=7.0.0",
15
+ ]
16
+ include = ["LICENSE"]
17
+
18
+ [project.entry-points.pytest11]
19
+ pytest_markdown_docs = "pytest_markdown_docs.plugin"
20
+
21
+ [build-system]
22
+ requires = ["hatchling"]
23
+ build-backend = "hatchling.build"
24
+
25
+ [tool.uv]
26
+ package=true
27
+ dev-dependencies = [
28
+ "mypy>=1.12.1",
29
+ "pre-commit>=3.5.0",
30
+ "pytest~=8.1.0",
31
+ "ruff>=0.7.0",
32
+ ]
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$">
6
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7
+ <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
8
+ <excludeFolder url="file://$MODULE_DIR$/dist" />
9
+ </content>
10
+ <orderEntry type="inheritedJdk" />
11
+ <orderEntry type="sourceFolder" forTests="false" />
12
+ </component>
13
+ </module>