mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Allow adding test cases testing version-dependent Python features (#9238)
This commit is contained in:
@@ -93,3 +93,17 @@ extensions, and since the tests need to pass on all Python versions >=3.7, PEP
|
||||
PEP 585 syntax can also not be used in the `test_cases` directory. Use
|
||||
`typing.Tuple` instead of `tuple`, `typing.Callable` instead of
|
||||
`collections.abc.Callable`, and `typing.Match` instead of `re.Match` (etc.).
|
||||
|
||||
### Version-dependent tests
|
||||
|
||||
Some tests will only pass on mypy
|
||||
with a specific Python version passed on the command line to the `tests/regr_test.py` script.
|
||||
To mark a test-case file as being skippable on lower versions of Python,
|
||||
append `-py3*` to the filename.
|
||||
For example, if `foo` is a stdlib feature that's new in Python 3.9,
|
||||
test cases for `foo` should be put in a file named `test_cases/stdlib/check_foo-py39.py`.
|
||||
This means that mypy will only run the test case
|
||||
if `--python-version 3.9`, `--python-version 3.10` or `--python-version 3.11`
|
||||
is passed on the command line to `tests/regr_test.py`,
|
||||
but it *won't* run the test case if `--python-version 3.7` or `--python-version 3.8`
|
||||
is passed on the command line.
|
||||
|
||||
Reference in New Issue
Block a user