Skip to content

Add stubs for WebTest #14541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add stubs for WebTest #14541

wants to merge 2 commits into from

Conversation

Daverball
Copy link
Contributor

A small testing framework for WSGI applications based around WebOb.

Source: https://github.com/Pylons/webtest/blob/3.0.6/webtest/__init__.py
Docs: https://docs.pylonsproject.org/projects/webtest/en/latest/

webtest.forms.Form turned out a little more lax than I would've liked. But making it more strict would've probably caused quite a bit of churn in test code, like not being able to use Checkbox.checked without first doing an isinstance check, or either having to do the same for Select.select/MultipleSelect.select_multiple or having to switch to Form.select/Form.select_multiple.

I also debated for a while on whether or not to make TestApp generic, but ultimately it seemed worth it, since if you have a test fixture that returns a TestApp, you don't necessarily want to have to specify another fixture in order to get at the WSGIApplication that's being tested with the correct type information. Giving the TypeVar a default of WSGIApplication should end up making it behave more or less the same as the non-generic version, if you don't care about being able to access the application through TestApp.app.

Copy link
Contributor

github-actions bot commented Aug 7, 2025

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@donBarbos
Copy link
Contributor

Thanks for contributing! I couldn't find any prior discussion about adding type hints directly to the package, but it does seem like preferred option, so I think it's worth opening an issue to suggest this idea to WebTest maintainers.
(If you've seen such a discussion, you can attach link in your PR message as one of the reasons for adding stubs to typeshed)

@Daverball
Copy link
Contributor Author

Thanks for contributing! I couldn't find any prior discussion about adding type hints directly to the package, but it does seem like preferred option, so I think it's worth opening an issue to suggest this idea to WebTest maintainers. (If you've seen such a discussion, you can attach link in your PR message as one of the reasons for adding stubs to typeshed)

Considering my PR to add my WebOb stubs as inline type hints to WebOb has been open for half a year without so much as a peep from a maintainer and them both being Pylons projects I decided not to bother spending the extra amount of time required to add inline hints, and I needed the stubs for something I was working on anyways, so it was quicker to just get it done. So since I already had them I decided to just contribute them.

That being said, WebTest does have a different maintainer, which appears to be ever so slightly more active, so I'm willing to try: Pylons/webtest#271

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants