pytest plugin for writing tests for mypy plugins
Project description
pytest plugin for testing mypy types, stubs, and plugins
Installation
pip install pytest-mypy-plugins
Usage
Examples of a test case:
# typesafety/test_request.yml
- case: request_object_has_user_of_type_auth_user_model
disable_cache: true
main: |
from django.http.request import HttpRequest
reveal_type(HttpRequest().user) # N: Revealed type is 'myapp.models.MyUser'
# check that other fields work ok
reveal_type(HttpRequest().method) # N: Revealed type is 'Union[builtins.str, None]'
files:
- path: myapp/__init__.py
- path: myapp/models.py
content: |
from django.db import models
class MyUser(models.Model):
pass
Running:
pytest
Options
mypy-tests:
--mypy-testing-base=MYPY_TESTING_BASE
Base directory for tests to use
--mypy-ini-file=MYPY_INI_FILE
Which .ini file to use as a default config for tests
--mypy-same-process
Now, to help with various issues in django-stubs, it runs every single test in the subprocess mypy call.
Some debuggers cannot attach to subprocess, so enable this flag to make mypy check happen in the same process.
(Could cause cache issues)
Further reading
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-mypy-plugins-1.1.0.tar.gz
.
File metadata
- Download URL: pytest-mypy-plugins-1.1.0.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2aa73a7081dbb03dadfa3d2e7bc8d06544931799ef0d26d77c76519bcbaabe4b |
|
MD5 | 9ff954a125906a2abff75368d8786a37 |
|
BLAKE2b-256 | ddea383047166fa5864ef44bd4dc623b9de58612742ac83d7b48f8523e8d28c0 |
File details
Details for the file pytest_mypy_plugins-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_mypy_plugins-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc754203133ab528e66b0feb3466a4a2f6a5ac274e0d9c571d42c1e9c5d24aa4 |
|
MD5 | e9b017e6b02cedceadd7b41f72984785 |
|
BLAKE2b-256 | 776aa8fa195ab1f638ddd9f2d0bd86db1c653ca127da463b6fa1acd75441858e |