Skip to content

gh-131178: Add tests for http.server command-line interface #132540

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 42 commits into
base: main
Choose a base branch
from

Conversation

ggqlq
Copy link

@ggqlq ggqlq commented Apr 15, 2025

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 15, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Apr 15, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Apr 15, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@ggqlq ggqlq changed the title Add tests for http.server command-line interface gh-131178: Add tests for http.server command-line interface Apr 15, 2025
@ggqlq ggqlq requested a review from donBarbos April 16, 2025 08:32
Copy link
Contributor

@donBarbos donBarbos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't read everything carefully yet, but this is what catches my eye first

ggqlq and others added 9 commits April 16, 2025 21:31
Co-authored-by: Semyon Moroz <[email protected]>
Co-authored-by: Semyon Moroz <[email protected]>
Co-authored-by: Semyon Moroz <[email protected]>
Co-authored-by: Semyon Moroz <[email protected]>
Co-authored-by: Semyon Moroz <[email protected]>
Co-authored-by: Semyon Moroz <[email protected]>
Co-authored-by: Semyon Moroz <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Apr 17, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@bedevere-app
Copy link

bedevere-app bot commented Apr 17, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While mocking seems fine, I feel that we're just checking how the test function is being called, but we're not testing whether it works or not.

@ggqlq
Copy link
Author

ggqlq commented Apr 18, 2025

@picnixz Thanks for your review! I use mock instead of testing the whole server because starting a real HTTP server would take much more time. Also, the result might be influenced by other applications and processes. We can assume that the server will work normally if we call the test function correctly because we have already tested the test function in the ScriptTestCase class. Should we add more test cases without mock to see if the server can be started and run normally?

@picnixz
Copy link
Member

picnixz commented Apr 18, 2025

Thanks for your review! I use mock instead of testing the whole server because starting a real HTTP server would take much more time. Also, the result might be influenced by other applications and processes. We can assume that the server will work normally if we call the test function correctly because we have already tested the test function in the ScriptTestCase class

IIRC, there are tests that use real servers (but correct me if I'm wrong), and we have a helper for finding the next available port in case. I don't think the tests will take long. It's just about serving files over HTTPS. However, just check that we're indeed covering everything in ScriptTestCase.

@ggqlq ggqlq requested review from donBarbos and picnixz May 6, 2025 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants