File: test_mypy_tests_in_test_file.py

package info (click to toggle)
pytest-mypy-testing 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 268 kB
  • sloc: python: 1,151; sh: 13; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 562 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# SPDX-FileCopyrightText: David Fritzsche
# SPDX-License-Identifier: CC0-1.0

# flake8: noqa
# ruff: noqa

import pytest


@pytest.mark.mypy_testing
def err():
    import foo  # E: Cannot find implementation or library stub for module named 'foo'


@pytest.mark.mypy_testing
def test_invalid_assginment():
    """An example test function to be both executed and mypy-tested"""
    foo = "abc"
    foo = 123  # E: Incompatible types in assignment (expression has type "int", variable has type "str")
    assert foo == 123
    reveal_type(123)  # R: Literal[123]?