Commit Graph

22 Commits

Author SHA1 Message Date
Adam Turner
c4daa95c09 Enable the entire D category in Ruff 2025-01-14 15:55:02 +00:00
Adam Turner
801c60a873 Consistently calculate the current file's directory 2024-11-03 17:28:02 +00:00
Adam Turner
903da2046e Enable the PLR1714 lint in Ruff 2024-10-19 19:05:43 +01:00
Adam Turner
d03156e078
Format `tests/` (#12760) 2024-08-11 14:58:56 +01:00
James Addison
df3cde65fa
[tests] linkcheck: bind each test HTTP server to a unique port per-testcase (#12126)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-04-04 11:25:53 +02:00
James Addison
078a80a42d
[refactor] test utils: simplify signatures and remove from ruff exclusion list. (#12155)
Apply some small method-signature cleanups in `tests/utils.py`,
and remove it from the `ruff format` exclusion list.
2024-03-21 11:08:35 +01:00
James Addison
b7f708dc63
[tests] utils: refactor type-hint signatures. (#12144)
Consolidate the provision of a single `http_server` utility method, with `tls_enabled` as a boolean flag,
and rework type annotations to make them more understandable.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Chris Sewell <chrisj_sewell@hotmail.com>
2024-03-20 23:13:41 +01:00
Bénédikt Tran
2df5b0a8ab
[lint] whitelist all test files except configuration and utils in tests (#12109) 2024-03-16 18:06:58 +01:00
James Addison
c6bd97ceae
Revert "tests: implement readiness check before yielding local-http(s) test servers" (#12078) 2024-03-14 09:01:17 +01:00
James Addison
1bfddf81e0
[CI/CD] implement readiness check before yielding local-http(s) test servers (#12050)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-03-08 11:16:31 +01:00
James Addison
566e4e74a0
Use HTTP/1.1 in linkcheck test webservers (#11392) 2023-07-22 20:12:32 +01:00
Martin Liška
a80e3fd377
Use a shared file-system lock in `create_server` (#11294)
With parallel run of tests, one gets "Address already in use" errors
as all tests attempt to bind to the same port. Fix it with a shared
file-system lock.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-04-06 22:24:49 +01:00
Adam Turner
97f07ca83c Speed up `test_linkcheck` 2023-03-24 00:29:27 +00:00
Takeshi KOMIYA
dcfc3f60ec refactor: ssl.wrap_context() has been deprecated now 2021-12-11 11:38:24 +09:00
Jon Dufresne
c1437d5f79 Replace modify_env() with pytest monkeypatch.setenv()
The same test utility function is built into pytest. Can avoid the
duplication.

https://docs.pytest.org/en/latest/monkeypatch.html#monkeypatching-environment-variables
2020-11-27 14:10:36 -08:00
François Freitag
236afac7fd
Unset env variables in tests by del os.environ
The `unsetenv()` operation does not update `os.environ`.
https://docs.python.org/3/library/os.html#os.unsetenv
2020-11-26 21:12:28 +01:00
Takeshi KOMIYA
b615fcca85
Merge pull request #8436 from francoisfreitag/better-certs
linkcheck: Specify subjectAltName in test self-signed certificate
2020-11-16 02:42:34 +09:00
François Freitag
3c4e1c30b1
linkcheck: Specify subjectAltName in test self-signed certificate
Clears warning:

tests/test_build_linkcheck.py::test_connect_to_selfsigned_with_tls_cacerts
tests/test_build_linkcheck.py::test_connect_to_selfsigned_with_requests_env_var
  …/venv/lib/python3.8/site-packages/urllib3/connection.py:455: SubjectAltNameWarning: Certificate for localhost has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.)
    warnings.warn(
2020-11-15 18:25:39 +01:00
François Freitag
5eb74d5c8e
tests: Always cleanup when exiting modify_env context manager
Previously, an exception would leave the environment changed.
2020-11-15 10:25:36 +01:00
François Freitag
d453088b58
linkcheck: Prevent REQUESTS_CA_BUNDLE leak in tests
Test `test_connect_to_selfsigned_nonexistent_cert_file` serves two
purposes:
- verify the behavior when the CA bundle file path is incorrect
- flag a leak of REQUESTS_CA_BUNDLE

Assumes that test runs after
`test_connect_to_selfsigned_with_requests_env_var`. Not great, but
better than no testing.
2020-11-14 19:58:02 +01:00
François Freitag
10e11f3133
linkcheck: Verify behavior with self-signed certs 2020-11-14 12:59:29 +01:00
François Freitag
0178437f3c
Rewrite test_inspect_main_url to avoid mocking
Makes the test more realistic by issuing an HTTP request.
Reduces coupling between test and the code under test.

The `http_server` helper was factored out into a new tests.utils module.
2020-11-08 22:30:49 +01:00