mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-22 01:28:29 +08:00
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:
13
stubs/requests/@tests/test_cases/check_post.py
Normal file
13
stubs/requests/@tests/test_cases/check_post.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# pyright: reportUnnecessaryTypeIgnoreComment=true
|
||||
|
||||
import requests
|
||||
|
||||
# Regression test for #7988 (multiple files should be allowed for the "files" argument)
|
||||
# This snippet comes from the requests documentation (https://requests.readthedocs.io/en/latest/user/advanced/#post-multiple-multipart-encoded-files),
|
||||
# so should pass a type checker without error
|
||||
url = "https://httpbin.org/post"
|
||||
multiple_files = [
|
||||
("images", ("foo.png", open("foo.png", "rb"), "image/png")),
|
||||
("images", ("bar.png", open("bar.png", "rb"), "image/png")),
|
||||
]
|
||||
r = requests.post(url, files=multiple_files)
|
||||
Reference in New Issue
Block a user