| -- Test cases for reporting errors when a test case uses a fixture with |
| -- missing definitions. At least in the most common cases this should not |
| -- result in an uncaught exception. These tests make sure that this behavior |
| -- does not regress. |
| -- |
| -- NOTE: These tests do NOT test behavior of mypy outside tests. |
| |
| [case testVariableUndefinedUsingDefaultFixture] |
| import m |
| # This used to cause a crash since types.ModuleType is not available |
| # by default. We fall back to 'object' now. |
| m.x # E: "object" has no attribute "x" |
| [file m.py] |
| |
| [case testListMissingFromStubs] |
| from typing import List |
| def f(x: List[int]) -> None: pass |
| [out] |
| main:1: error: Module 'typing' has no attribute 'List' |
| main:1: note: Maybe your test fixture does not define "builtins.list"? |
| main:1: note: Consider adding [builtins fixtures/list.pyi] to your test description |
| |
| [case testDictMissingFromStubs] |
| from typing import Dict |
| def f(x: Dict[int]) -> None: pass |
| [out] |
| main:1: error: Module 'typing' has no attribute 'Dict' |
| main:1: note: Maybe your test fixture does not define "builtins.dict"? |
| main:1: note: Consider adding [builtins fixtures/dict.pyi] to your test description |
| |
| [case testSetMissingFromStubs] |
| from typing import Set |
| def f(x: Set[int]) -> None: pass |
| [out] |
| main:1: error: Module 'typing' has no attribute 'Set' |
| main:1: note: Maybe your test fixture does not define "builtins.set"? |
| main:1: note: Consider adding [builtins fixtures/set.pyi] to your test description |
| |
| [case testBaseExceptionMissingFromStubs] |
| e: BaseException |
| [out] |
| main:1: error: Name 'BaseException' is not defined |
| main:1: note: Maybe your test fixture does not define "builtins.BaseException"? |
| main:1: note: Consider adding [builtins fixtures/exception.pyi] to your test description |
| |
| [case testExceptionMissingFromStubs] |
| e: Exception |
| [out] |
| main:1: error: Name 'Exception' is not defined |
| main:1: note: Maybe your test fixture does not define "builtins.Exception"? |
| main:1: note: Consider adding [builtins fixtures/exception.pyi] to your test description |
| |
| [case testIsinstanceMissingFromStubs] |
| if isinstance(1, int): |
| pass |
| [out] |
| main:1: error: Name 'isinstance' is not defined |
| main:1: note: Maybe your test fixture does not define "builtins.isinstance"? |
| main:1: note: Consider adding [builtins fixtures/isinstancelist.pyi] to your test description |
| |
| [case testInvalidTupleDefinitionFromStubs] |
| from typing import Tuple |
| x: Tuple[int, ...] |
| x[0] |
| for y in x: |
| pass |
| [out] |
| -- These errors are pretty bad, but keeping this test anyway to |
| -- avoid things getting worse. |
| main:3: error: Value of type "Tuple[int, ...]" is not indexable |
| main:4: error: "Tuple[int, ...]" has no attribute "__iter__" (not iterable) |
| |
| [case testClassmethodMissingFromStubs] |
| class A: |
| @classmethod |
| def f(cls): pass |
| [out] |
| main:2: error: Name 'classmethod' is not defined |
| main:2: note: Maybe your test fixture does not define "builtins.classmethod"? |
| main:2: note: Consider adding [builtins fixtures/classmethod.pyi] to your test description |
| |
| [case testPropertyMissingFromStubs] |
| class A: |
| @property |
| def f(self): pass |
| [out] |
| main:2: error: Name 'property' is not defined |
| main:2: note: Maybe your test fixture does not define "builtins.property"? |
| main:2: note: Consider adding [builtins fixtures/property.pyi] to your test description |