pytest-markdown-docs 0.5.0__tar.gz → 0.6.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.
@@ -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
@@ -1,22 +1,14 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: pytest-markdown-docs
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Run markdown code fences through pytest
5
- Home-page: https://github.com/modal-com/pytest-markdown-docs
6
- License: MIT
7
5
  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
6
+ Author-email: Elias Freider <elias@modal.com>
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.8
10
+ Requires-Dist: markdown-it-py<4.0,>=2.2.0
11
+ Requires-Dist: pytest>=7.0.0
20
12
  Description-Content-Type: text/markdown
21
13
 
22
14
  # Pytest Markdown Docs
@@ -157,6 +149,25 @@ assert a + " world" == "hello world"
157
149
  ```
158
150
  ````
159
151
 
152
+ ## MDX Comments for Metadata Options
153
+ 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:
154
+
155
+ ```mdx
156
+ {/* pmd-metadata: notest fixture:capsys */}
157
+ ```python
158
+ print("hello")
159
+ captured = capsys.readouterr()
160
+ assert captured.out == "hello\n"
161
+ ```
162
+
163
+ The following options can be specified using MDX comments:
164
+
165
+ * notest: Exclude the code block from testing.
166
+ * fixture:<name>: Apply named pytest fixtures to the code block.
167
+ * continuation: Continue from the previous code block, allowing you to carry over state.
168
+
169
+ This approach allows you to add metadata to the code block without modifying the code fence itself, making it particularly useful in MDX environments.
170
+
160
171
  ## Testing of this plugin
161
172
 
162
173
  You can test this module itself (sadly not using markdown tests at the moment) using pytest:
@@ -177,4 +188,4 @@ Or for fun, you can use this plugin to include testing of the validity of snippe
177
188
  * Line numbers are "wrong" for docstring-inlined snippets (since we don't know where in the file the docstring starts)
178
189
  * Line numbers are "wrong" for continuation blocks even in pure markdown files (can be worked out with some refactoring)
179
190
  * 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".
180
- * Assertions are not rewritten w/ pretty data structure inspection like they are with regular pytest tests by default
191
+ * Assertions are not rewritten w/ pretty data structure inspection like they are with regular pytest tests by default
@@ -136,6 +136,25 @@ assert a + " world" == "hello world"
136
136
  ```
137
137
  ````
138
138
 
139
+ ## MDX Comments for Metadata Options
140
+ 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:
141
+
142
+ ```mdx
143
+ {/* pmd-metadata: notest fixture:capsys */}
144
+ ```python
145
+ print("hello")
146
+ captured = capsys.readouterr()
147
+ assert captured.out == "hello\n"
148
+ ```
149
+
150
+ The following options can be specified using MDX comments:
151
+
152
+ * notest: Exclude the code block from testing.
153
+ * fixture:<name>: Apply named pytest fixtures to the code block.
154
+ * continuation: Continue from the previous code block, allowing you to carry over state.
155
+
156
+ This approach allows you to add metadata to the code block without modifying the code fence itself, making it particularly useful in MDX environments.
157
+
139
158
  ## Testing of this plugin
140
159
 
141
160
  You can test this module itself (sadly not using markdown tests at the moment) using pytest: