Skip to main content

pytest plugin for writing tests for mypy plugins

Project description

mypy logo

pytest plugin for testing mypy types, stubs, and plugins

Build Status Checked with mypy Gitter

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
- case: with_params
  parametrized:
    - val: 1
      rt: builtins.int
    - val: 1.0
      rt: builtins.float
  main: |
    reveal_type({[ val }})  # N: Reveal type is '{{ rt }}'

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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-mypy-plugins-1.4.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

pytest_mypy_plugins-1.4.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest-mypy-plugins-1.4.0.tar.gz.

File metadata

  • Download URL: pytest-mypy-plugins-1.4.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for pytest-mypy-plugins-1.4.0.tar.gz
Algorithm Hash digest
SHA256 f1a1d34bf01cb6d8bf455409ed4e391c0b2f0a64cb0f6e743db975bcafcc8cf2
MD5 5309cc08601b8846dff5c07aefbc315a
BLAKE2b-256 df615f65d5e71d79c8a5a4bc2910a26b31ec1735b6c00999f4d481ac7977f0c8

See more details on using hashes here.

File details

Details for the file pytest_mypy_plugins-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_mypy_plugins-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for pytest_mypy_plugins-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 baa43948e9873220876fae86dbefc69727803b2df8c20f8164ff0be9823e91d7
MD5 bba12c63e5f1b27876fe9fcdcedb5c30
BLAKE2b-256 9e299db98741851d2d59fb6770df261dfeb6e77750cdbe80e9d295c35a28e4f2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page