File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -156,6 +156,45 @@ This is an example of a parametrized test with ``pytest-mypy-plugins``:
156
156
main : |
157
157
reveal_type({[ val }}) # N: Revealed type is '{{ rt }}'
158
158
159
+ pytest-mypy-testing
160
+ -------------------
161
+
162
+ `pytest-mypy-testing <https://github.com/davidfritzsche/pytest-mypy-testing >`_ is another
163
+ plugin for ``pytest ``. The main difference between :ref: `pytest-mypy-plugins ` is that
164
+ :ref: `pytest-mypy-testing ` allows writing tests inside Python code and/or
165
+ mixed with actual tests.
166
+
167
+ .. warning ::
168
+
169
+ pytest-mypy-testing uses the Python
170
+ `ast<https://docs.python.org/3/library/ast.html> `_ module to parse
171
+ candidate files and does not import any file, i.e., the decorator must be
172
+ exactly named ``@pytest.mark.mypy_testing ``!
173
+
174
+
175
+ These are examples of testing with ``pytest-mypy-testing ``:
176
+
177
+ .. code-block :: python
178
+
179
+ @pytest.mark.mypy_testing
180
+ def mypy_use_reveal_type ():
181
+ reveal_type(123 ) # N: Revealed type is 'Literal[123]?'
182
+ reveal_type(456 ) # R: Literal[456]?
183
+
184
+ .. code-block :: python
185
+
186
+ def foo (num : int ) -> str :
187
+ return str (num)
188
+
189
+
190
+ @pytest.mark.mypy_testing
191
+ def test_foo ():
192
+ result = foo(1 )
193
+ reveal_type(result) # R: builtins.str
194
+
195
+ assert result == " 1"
196
+
197
+
159
198
Improving Type Completeness
160
199
===========================
161
200
You can’t perform that action at this time.
0 commit comments