pytest plugin to test mypy static type analysis

Overview

PyPI GitHub Action Status License License: MIT

pytest-mypy-testing — Plugin to test mypy output with pytest

pytest-mypy-testing provides a pytest plugin to test that mypy produces a given output. As mypy can be told to display the type of an expression this allows us to check mypys type interference.

Installation

python -m pip install pytest-mypy-testing

The Python distribution package contains an entry point so that the plugin is automatically discovered by pytest. To disable the plugin when it is installed , you can use the pytest command line option -p no:mypy-testing.

Writing Mypy Output Test Cases

A mypy test case is a top-level functions decorated with @pytest.mark.mypy_testing in a file named *.mypy-testing or in a pytest test module. pytest-mypy-testing follows the pytest logic in identifying test modules and respects the python_files config value.

Note that pytest-mypy-testing uses the Python ast module to parse candidate files and does not import any file, i.e., the decorator must be exactly named @pytest.mark.mypy_testing.

In a pytest test module file you may combine both regular pytest test functions and mypy test functions. A single function can be both.

Example: A simple mypy test case could look like this:

@pytest.mark.mypy_testing
def mypy_test_invalid_assignment() -> None:
    foo = "abc"
    foo = 123  # E: Incompatible types in assignment (expression has type "int", variable has type "str")

The plugin runs mypy for every file containing at least one mypy test case. The mypy output is then compared to special Python comments in the file:

  • # N: <msg> - we expect a mypy note message
  • # W: <msg> - we expect a mypy warning message
  • # E: <msg> - we expect a mypy error message
  • # R: <msg> - we expect a mypy note message Revealed type is '<msg>'. This is useful to easily check reveal_type output:
    @pytest.mark.mypy_testing
    def mypy_use_reveal_type():
        reveal_type(123)  # N: Revealed type is 'Literal[123]?'
        reveal_type(456)  # R: Literal[456]?

Skipping and Expected Failures

Mypy test case functions can be decorated with @pytest.mark.skip and @pytest.mark.xfail to mark them as to-be-skipped and as expected-to-fail, respectively. As with the @pytest.mark.mypy_testing mark, the names must match exactly as the decorators are extracted from the ast.

Development

  • Create and activate a Python virtual environment.
  • Install development dependencies by calling python -m pip install -U -r requirements.txt.
  • Start developing.
  • To run all tests with tox, Python 3.6, 3.7 and 3.8 must be available. You might want to look into using pyenv.

Changelog

v0.0.7

  • Fix PYTEST_VERSION_INFO - by @blueyed (#8)
  • Always pass --check-untyped-defs to mypy (#11)
  • Respect pytest config python_files when identifying pytest test modules (#12)

v0.0.6 - add pytest 5.4 support

  • Update the plugin to work with pytest 5.4 (#7)

v0.0.5 - CI improvements

  • Make invoke tasks work (partially) on Windows (#6)
  • Add an invoke task to run tox environments by selecting globs (e.g., inv tox -e py-*) (#6)
  • Use coverage directly for code coverage to get more consistent parallel run results (#6)
  • Use flit fork dflit to make packaging work with LICENSES directory (#6)
  • Bump dependencies (#6)
Comments
  • Improve

    Improve "unexpected" failure: include following/extra messages

    It would be useful if following messages would also be displayed in case of mismatches, e.g. with these message (in diff_message_sequences):

    (Pdb++) pp actual_messages
    [Message(filename='…/test_typing.py', lineno=1, colno=1, severity=<Severity.ERROR: 3>, message="No library stub file for module 'foo'"),
     Message(filename='…/test_typing.py', lineno=1, colno=1, severity=<Severity.NOTE: 1>, message='(Stub files are from https://github.com/python/typeshed)'),
     Message(filename='…/test_typing.py', lineno=7, colno=11, severity=<Severity.ERROR: 3>, message='Incompatible types in assignment (expression has type "int", variable has type "str")')]
    (Pdb++) expected_messages
    [Message(filename='…/test_typing.py', lineno=7, colno=None, severity=<Severity.ERROR: 3>, message='Incompatible types in assignment (expression has type "int", variable has type "str")')]
    

    You only see:

    ============ FAILURES ============
    ___ [mypy]mypy_use_reveal_type ___
    …/test_typing.py:1: note (unexpected): (Stub files are from https://github.com/python/typeshed)
    

    So the actual message is there already, but only after initial error/notes.

    opened by blueyed 5
  • Some messages not found when running pytest as `python -m pytest` against mypy 0.971

    Some messages not found when running pytest as `python -m pytest` against mypy 0.971

    I don't think this is enough information to be actionable, but I hope I'm wrong, and I need some feedback on where to look next.

    My typing tests started failing under mypy 0.971; reverting to 0.961 fixed the issue. All of the failures took the form of an expected message not being present. I was unable to replicate this issue in a small test file, but if I moved that file into the test folder, it exhibited the issue, even if tested individually.

    Things that make the issue go away:

    • Invoking pytest with pytest instead of python -m pytest
    • Downgrading mypy to 0.961
    • Testing the same file in a different tree (?)

    Things that don't make the issue go away:

    • Collecting only a subset of test files

    Of note, if I just collect the small test file, in the main tree (so I can hit the issue), then invoking python -m pytest (which hits the issue) completes in 0.05s pretty consistently, while invoking pytest (which does not) tends to take over 7s.

    I was poking around trying to replicate things, and I can't see any significant difference in the output from mypy.api.run between versions.

    I wish I had more to go on here, but that's what I've found so far.

    opened by mwchase 4
  • Problem using plugin on Windows?

    Problem using plugin on Windows?

    Ran into a problem with running this on windows. Im not entirely sure whats special about my setup that would cause this.

    Relevant line from attached error message

    line = "C:\\Users\\eehusky\\anaconda3\\lib\\site-packages\\_pytest\\_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
    
        @classmethod
        def from_output(cls, line: str) -> "Message":
            m = cls.OUTPUT_RE.match(line)
            if not m:
    >           raise ValueError("Not a valid mypy message")
    E           ValueError: Not a valid mypy message
    

    Brass tacks, It think the entire absolute path getting included and is messing with the regex.

    I think it is getting hung up on the C: in the file path in mypy messages. But I am by no means a regex guru so Ill withhold judgement.

    OUTPUT_RE = re.compile(
            r"^(?P<fname>[^:]+):"   # << This 
            r"(?P<lineno>[0-9]+):"
            r"((?P<colno>[0-9]+):)?"
            r" *(?P<severity>(error|note|warning)):"
            r"(?P<message>.*)$"
        )
    

    I did mess around with this a bit and found if i removed the C: from the text it would work fine.

    import os
    import re
    OUTPUT_RE = re.compile(
            r"^(?P<fname>[^:]+):"
            r"(?P<lineno>[0-9]+):"
            r"((?P<colno>[0-9]+):)?"
            r" *(?P<severity>(error|note|warning)):"
            r"(?P<message>.*)$"
        )
    
    def from_output(line: str) -> "Message":
        m = OUTPUT_RE.match(line)
        if not m:
            raise ValueError("Not a valid mypy message")
        return (
            os.path.abspath(m.group("fname")),
            int(m.group("lineno")),
            int(m.group("colno")) if m.group("colno") else None,
            m.group("severity").upper(),
            m.group("message").strip(),
        )
    
    
    line = "C/Users/eehusky/anaconda3/lib/site-packages/_pytest/_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
    print(from_output(line))
    line = "C:/Users/eehusky/anaconda3/lib/site-packages/_pytest/_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
    print(from_output(line))
    

    Output from above test

    ('C:\\Users\\eehusky\\anaconda3\\lib\\site-packages\\_pytest\\_argcomplete.py', 103, 1, 'ERROR', "Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs")
    ----------------------------------------------------------------------
    ValueError                           Traceback (most recent call last)
    <ipython-input-17-f28f32de0f3a> in <module>
         25 print(from_output(line))
         26 line = "C:/Users/eehusky/anaconda3/lib/site-packages/_pytest/_argcomplete.py:103:1: error: Skipping analyzing 'argcomplete.completers': found module but no type hints or library stubs"
    ---> 27 print(from_output(line))
    
    <ipython-input-17-f28f32de0f3a> in from_output(line)
         12     m = OUTPUT_RE.match(line)
         13     if not m:
    ---> 14         raise ValueError("Not a valid mypy message")
         15     return (
         16         os.path.abspath(m.group("fname")),
    
    ValueError: Not a valid mypy message
    

    Cheers, -Brandon

    output.txt

    opened by eehusky 2
  • Disable soft error limit

    Disable soft error limit

    Especially with --no-silence-site-packages newer versions of mypy can produce a number of errors that's over the soft error limit which defaults to 200. By setting it to -1, we disable it, which makes sense for something as predictable as a diff of expected vs. actual errors.

    (Not sure why we have --no-silence-site-packages in the arguments, but that's a separate question.)

    opened by ikonst 1
  • Bump py from 1.8.1 to 1.10.0

    Bump py from 1.8.1 to 1.10.0

    Bumps py from 1.8.1 to 1.10.0.

    Changelog

    Sourced from py's changelog.

    1.10.0 (2020-12-12)

    • Fix a regular expression DoS vulnerability in the py.path.svnwc SVN blame functionality (CVE-2020-29651)
    • Update vendored apipkg: 1.4 => 1.5
    • Update vendored iniconfig: 1.0.0 => 1.1.1

    1.9.0 (2020-06-24)

    • Add type annotation stubs for the following modules:

      • py.error
      • py.iniconfig
      • py.path (not including SVN paths)
      • py.io
      • py.xml

      There are no plans to type other modules at this time.

      The type annotations are provided in external .pyi files, not inline in the code, and may therefore contain small errors or omissions. If you use py in conjunction with a type checker, and encounter any type errors you believe should be accepted, please report it in an issue.

    1.8.2 (2020-06-15)

    • On Windows, py.path.locals which differ only in case now have the same Python hash value. Previously, such paths were considered equal but had different hashes, which is not allowed and breaks the assumptions made by dicts, sets and other users of hashes.
    Commits
    • e5ff378 Update CHANGELOG for 1.10.0
    • 94cf44f Update vendored libs
    • 5e8ded5 testing: comment out an assert which fails on Python 3.9 for now
    • afdffcc Rename HOWTORELEASE.rst to RELEASING.rst
    • 2de53a6 Merge pull request #266 from nicoddemus/gh-actions
    • fa1b32e Merge pull request #264 from hugovk/patch-2
    • 887d6b8 Skip test_samefile_symlink on pypy3 on Windows
    • e94e670 Fix test_comments() in test_source
    • fef9a32 Adapt test
    • 4a694b0 Add GitHub Actions badge to README
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Bump jinja2 from 2.11.2 to 2.11.3

    Bump jinja2 from 2.11.2 to 2.11.3

    Bumps jinja2 from 2.11.2 to 2.11.3.

    Release notes

    Sourced from jinja2's releases.

    2.11.3

    This contains a fix for a speed issue with the urlize filter. urlize is likely to be called on untrusted user input. For certain inputs some of the regular expressions used to parse the text could take a very long time due to backtracking. As part of the fix, the email matching became slightly stricter. The various speedups apply to urlize in general, not just the specific input cases.

    Changelog

    Sourced from jinja2's changelog.

    Version 2.11.3

    Released 2021-01-31

    • Improve the speed of the urlize filter by reducing regex backtracking. Email matching requires a word character at the start of the domain part, and only word characters in the TLD. :pr:1343
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 1
  • Cannot get README example to pass

    Cannot get README example to pass

    Hi I'm trying to get started with using your project, but I can't even get a simple test to pass.

    $ pytest --verbose
    ======================================= test session starts =======================================
    platform linux -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1 -- /home/user/.virtualenvs/virtualenv_name/bin/python
    cachedir: .pytest_cache
    rootdir: /home/user/project, inifile: pytest.ini
    plugins: mypy-testing-0.0.6
    collected 1 item                                                                                  
    
    tests/test_example.py::[mypy]mypy_test_invalid_assginment FAILED                            [100%]
    
    ============================================ FAILURES =============================================
    _______________________________ [mypy]mypy_test_invalid_assginment ________________________________
    /home/user/project/tests/test_example.py:7: error (missing): Incompatible types in assignment (expression has type "int", variable has type "str")
    ======================================== warnings summary =========================================
    tests/test_example.py::[mypy]mypy_test_invalid_assginment
      /home/user/.virtualenvs/virtualenv_name/lib/python3.8/distutils/__init__.py:1: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
        import imp
    
    -- Docs: https://docs.pytest.org/en/latest/warnings.html
    ===================================== short test summary info =====================================
    FAILED tests/test_example.py::[mypy]mypy_test_invalid_assginment - 
    ================================== 1 failed, 1 warning in 1.26s ===================================
    

    where my test file contains just the example from the README:

    import pytest  # type: ignore
    
    
    @pytest.mark.mypy_testing
    def mypy_test_invalid_assginment():
        foo = "abc"
        foo = 123  # E: Incompatible types in assignment (expression has type "int", variable has type "str")
    

    Am I missing something vital to use this project?

    opened by BryceBeagle 1
  • Fix PYTEST_VERSION_INFO

    Fix PYTEST_VERSION_INFO

    It currently fails with editable pytest installations (due to setuptools-scm version):

    PYTEST_VERISON_INFO = tuple(int(part) for part in PYTEST_VERSION.split("."))
    ValueError: invalid literal for int() with base 10: 'dev42+g134a7d26d'
    
    opened by blueyed 0
  • Bump setuptools from 65.3.0 to 65.5.1

    Bump setuptools from 65.3.0 to 65.5.1

    Bumps setuptools from 65.3.0 to 65.5.1.

    Changelog

    Sourced from setuptools's changelog.

    v65.5.1

    Misc ^^^^

    • #3638: Drop a test dependency on the mock package, always use :external+python:py:mod:unittest.mock -- by :user:hroncok
    • #3659: Fixed REDoS vector in package_index.

    v65.5.0

    Changes ^^^^^^^

    • #3624: Fixed editable install for multi-module/no-package src-layout projects.
    • #3626: Minor refactorings to support distutils using stdlib logging module.

    Documentation changes ^^^^^^^^^^^^^^^^^^^^^

    • #3419: Updated the example version numbers to be compliant with PEP-440 on the "Specifying Your Project’s Version" page of the user guide.

    Misc ^^^^

    • #3569: Improved information about conflicting entries in the current working directory and editable install (in documentation and as an informational warning).
    • #3576: Updated version of validate_pyproject.

    v65.4.1

    Misc ^^^^

    v65.4.0

    Changes ^^^^^^^

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump wheel from 0.37.1 to 0.38.1

    Bump wheel from 0.37.1 to 0.38.1

    Bumps wheel from 0.37.1 to 0.38.1.

    Changelog

    Sourced from wheel's changelog.

    Release Notes

    UNRELEASED

    • Updated vendored packaging to 22.0

    0.38.4 (2022-11-09)

    • Fixed PKG-INFO conversion in bdist_wheel mangling UTF-8 header values in METADATA (PR by Anderson Bravalheri)

    0.38.3 (2022-11-08)

    • Fixed install failure when used with --no-binary, reported on Ubuntu 20.04, by removing setup_requires from setup.cfg

    0.38.2 (2022-11-05)

    • Fixed regression introduced in v0.38.1 which broke parsing of wheel file names with multiple platform tags

    0.38.1 (2022-11-04)

    • Removed install dependency on setuptools
    • The future-proof fix in 0.36.0 for converting PyPy's SOABI into a abi tag was faulty. Fixed so that future changes in the SOABI will not change the tag.

    0.38.0 (2022-10-21)

    • Dropped support for Python < 3.7
    • Updated vendored packaging to 21.3
    • Replaced all uses of distutils with setuptools
    • The handling of license_files (including glob patterns and default values) is now delegated to setuptools>=57.0.0 (#466). The package dependencies were updated to reflect this change.
    • Fixed potential DoS attack via the WHEEL_INFO_RE regular expression
    • Fixed ValueError: ZIP does not support timestamps before 1980 when using SOURCE_DATE_EPOCH=0 or when on-disk timestamps are earlier than 1980-01-01. Such timestamps are now changed to the minimum value before packaging.

    0.37.1 (2021-12-22)

    • Fixed wheel pack duplicating the WHEEL contents when the build number has changed (#415)
    • Fixed parsing of file names containing commas in RECORD (PR by Hood Chatham)

    0.37.0 (2021-08-09)

    • Added official Python 3.10 support
    • Updated vendored packaging library to v20.9

    ... (truncated)

    Commits
    • 6f1608d Created a new release
    • cf8f5ef Moved news item from PR #484 to its proper place
    • 9ec2016 Removed install dependency on setuptools (#483)
    • 747e1f6 Fixed PyPy SOABI parsing (#484)
    • 7627548 [pre-commit.ci] pre-commit autoupdate (#480)
    • 7b9e8e1 Test on Python 3.11 final
    • a04dfef Updated the pypi-publish action
    • 94bb62c Fixed docs not building due to code style changes
    • d635664 Updated the codecov action to the latest version
    • fcb94cd Updated version to match the release
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump certifi from 2022.9.14 to 2022.12.7

    Bump certifi from 2022.9.14 to 2022.12.7

    Bumps certifi from 2022.9.14 to 2022.12.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Handle mypy error codes

    Handle mypy error codes

    Recent versions of mypy added string error codes next to the messages. I don't remember seeing this in older versions.

    If you have older pytest-mypy-testing assertions you have two options:

    • Adjust all assertion messages
    • Use "hide_error_codes = True" to make them still pass.

    It would be nice if this plugin would parse the message from mypy and allow matching based on error codes. Stability is not guaranteed but they're still likely to be more stable that messages. The fact that error codes are short strings would also alleviate #29.

    opened by cdleonard 0
  • new release required for recent pytest release

    new release required for recent pytest release

    Seeing the following error in my CI tests:

        File "/tmp/.tox/py310-macos/lib/python3.10/site-packages/pytest_mypy_testing/plugin.py", line 12, in <module>
          from py._path.local import LocalPath
      ModuleNotFoundError: No module named 'py._path'; 'py' is not a package
    

    looks like the changes from https://github.com/davidfritzsche/pytest-mypy-testing/pull/27 would fix it. any plans for a new version release?

    thanks!

    opened by tlambert03 0
  • Handling of long lines

    Handling of long lines

    In certain cases, we have a mypy assertion like:

    @pytest.mark.mypy_testing
    def test_foo():
        link = Link()
        link1.url = 123  # E: Incompatible types in assignment (expression has type "int", variable has type "Optional[str]")
    

    However, the last line already covers 122-characters. When using Black (which has a default of 88 chars - reference), it'd turn something like:

    @pytest.mark.mypy_testing
    def test_foo():
        link = Link()
        link1.url = (
            123
        )  # E: Incompatible types in assignment (expression has type "int", variable has type "Optional[str]")
    

    The issue with this new format is that pytest would error out with something like:

    5: error (unexpected): Incompatible types in assignment (expression has type "int", variable has type "Optional[str]")
    6: error (missing): Incompatible types in assignment (expression has type "int", variable has type "Optional[str]")
    

    Perhaps there should be another interface that could help declare the assertions aside from comments? or maybe, it should be possible to breakdown the comments into multi-line chunks?

    opened by BurnzZ 0
Releases(v0.0.7)
Owner
David Fritzsche
David Fritzsche
The Penetration Testers Framework (PTF) is a way for modular support for up-to-date tools.

The PenTesters Framework (PTF) is a Python script designed for Debian/Ubuntu/ArchLinux based distributions to create a similar and familiar distribution for Penetration Testing

trustedsec 4.5k Dec 28, 2022
a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)

pytest-sugar pytest-sugar is a plugin for pytest that shows failures and errors instantly and shows a progress bar. Requirements You will need the fol

Teemu 963 Dec 28, 2022
fsociety Hacking Tools Pack – A Penetration Testing Framework

Fsociety Hacking Tools Pack A Penetration Testing Framework, you will have every script that a hacker needs. Works with Python 2. For a Python 3 versi

Manisso 8.2k Jan 03, 2023
API Rest testing FastAPI + SQLAchmey + Docker

Transactions API Rest Implement and design a simple REST API Description We need to a simple API that allow us to register users' transactions and hav

TxeMac 2 Jun 30, 2022
Tattoo - System for automating the Gentoo arch testing process

Naming origin Well, naming things is very hard. Thankfully we have an excellent

Arthur Zamarin 4 Nov 07, 2022
WIP SAT benchmarking tooling, written with only my personal use in mind.

SAT Benchmarking Some early work in progress tooling for running benchmarks and keeping track of the results when working on SAT solvers and related t

Jannis Harder 1 Dec 26, 2021
This is a pytest plugin, that enables you to test your code that relies on a running MongoDB database

This is a pytest plugin, that enables you to test your code that relies on a running MongoDB database. It allows you to specify fixtures for MongoDB process and client.

Clearcode 19 Oct 21, 2022
Ward is a modern test framework for Python with a focus on productivity and readability.

Ward is a modern test framework for Python with a focus on productivity and readability.

Darren Burns 1k Dec 31, 2022
0hh1 solver for the web (selenium) and also for mobile (adb)

0hh1 - Solver Aims to solve the '0hh1 puzzle' for all the sizes (4x4, 6x6, 8x8, 10x10 12x12). for both the web version (using selenium) and on android

Adwaith Rajesh 1 Nov 05, 2021
Fail tests that take too long to run

GitHub | PyPI | Issues pytest-fail-slow is a pytest plugin for making tests fail that take too long to run. It adds a --fail-slow DURATION command-lin

John T. Wodder II 4 Nov 27, 2022
Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.

The Mixer is a helper to generate instances of Django or SQLAlchemy models. It's useful for testing and fixture replacement. Fast and convenient test-

Kirill Klenov 871 Dec 25, 2022
A rewrite of Python's builtin doctest module (with pytest plugin integration) but without all the weirdness

The xdoctest package is a re-write of Python's builtin doctest module. It replaces the old regex-based parser with a new abstract-syntax-tree based pa

Jon Crall 174 Dec 16, 2022
Python drivers for YeeNet firmware

yeenet-router-driver-python Python drivers for YeeNet firmware This repo is under heavy development. Many or all of these scripts are not likely to wo

Jason Paximadas 1 Dec 26, 2021
It helps to use fixtures in pytest.mark.parametrize

pytest-lazy-fixture Use your fixtures in @pytest.mark.parametrize. Installation pip install pytest-lazy-fixture Usage import pytest @pytest.fixture(p

Marsel Zaripov 299 Dec 24, 2022
Parameterized testing with any Python test framework

Parameterized testing with any Python test framework Parameterized testing in Python sucks. parameterized fixes that. For everything. Parameterized te

David Wolever 714 Dec 21, 2022
A Proof of concept of a modern python CLI with click, pydantic, rich and anyio

httpcli This project is a proof of concept of a modern python networking cli which can be simple and easy to maintain using some of the best packages

Kevin Tewouda 17 Nov 15, 2022
Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source.

Mockoon Mockoon is the easiest and quickest way to run mock APIs locally. No remote deployment, no account required, open source. It has been built wi

mockoon 4.4k Dec 30, 2022
AutoExploitSwagger is an automated API security testing exploit tool that can be combined with xray, BurpSuite and other scanners.

AutoExploitSwagger is an automated API security testing exploit tool that can be combined with xray, BurpSuite and other scanners.

6 Jan 28, 2022
Selenium-python but lighter: Helium is the best Python library for web automation.

Selenium-python but lighter: Helium Selenium-python is great for web automation. Helium makes it easier to use. For example: Under the hood, Helium fo

Michael Herrmann 3.2k Dec 31, 2022
Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

Prism is a set of packages for API mocking and contract testing with OpenAPI v2 (formerly known as Swagger) and OpenAPI v3.x. Mock Servers: Life-like

Stoplight 3.3k Jan 05, 2023