Add infrastructure allowing for test cases for third-party stubs (#8700)

- Move the logic for running mypy on the test cases from `tests/mypy_test.py` to a separate script, `tests/regr_test.py`.
- Add the necessary logic in order to be able to have test cases for third-party stubs.
- Move logic common to `tests/mypy_test.py` and `tests/regr_test.py` into `tests/colors.py`, and rename `tests/colors.py` to `tests/utils.py`.
- Add a new check to `tests/check_consistent.py`, to enforce the use of `# pyright: reportUnnecessaryTypeIgnoreComment=true` comments in third-party test cases. These are essential if we want to have our tests against false-negatives work with pyright.
- Update the relevant documentation to account for the new test file.
- Add a new job to the `tests.yml` GitHub workflow, to run the new test in CI.
- Add a simple proof-of-concept test case for `requests`, as a regression test for #7998.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
Alex Waygood
2022-09-08 16:51:33 +01:00
committed by GitHub
parent e4d0d3d9d7
commit b53843ab46
11 changed files with 346 additions and 113 deletions

View File

@@ -1,7 +1,7 @@
## Regression tests for typeshed
This directory contains code samples that act as a regression test for the
standard library stubs found elsewhere in the typeshed repo.
This directory contains code samples that act as a regression test for
typeshed's stdlib stubs.
**This directory should *only* contain test cases for functions and classes which
are known to have caused problems in the past, where the stubs are difficult to
@@ -9,6 +9,14 @@ get right.** 100% test coverage for typeshed is neither necessary nor
desirable, as it would lead to code duplication. Moreover, typeshed has
multiple other mechanisms for spotting errors in the stubs.
### Where are the third-party test cases?
Not all third-party stubs packages in typeshed have test cases, and not all of
them need test cases. For those that do have test cases, however, the samples
can be found in `@tests/test_cases` subdirectories for each stubs package. For
example, the test cases for `requests` can be found in the
`stubs/requests/@tests/test_cases` directory.
### The purpose of these tests
Different test cases in this directory serve different purposes. For some stubs in