conftest.py
This file
Path
tests/conftest.py
58 lines · 1.5 KiB · Python
Last changed by
Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
History of this fileTake it
The walk stopped after 200 commits: lines older than 8c211a9 point at it.
Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba
line 1why, one step back1try:Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
line 2why, one step back2 from http.server import HTTPServer, SimpleHTTPRequestHandlerStop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba
lines 3–4why, one step back3except ImportError:4 from BaseHTTPServer import HTTPServerAdd automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
line 5why, one step back5 from SimpleHTTPServer import SimpleHTTPRequestHandlerStop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba
lines 6–9why, one step back67import ssl8import threading9Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9
line 10why, one step back10import pytestAdd automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
line 11why, one step back11Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9
lines 12–16why, one step back12from requests.compat import urljoin131415def prepare_url(value):16 # Issue #1483: Make sure the URL always has a trailing slashAdd automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
line 17why, one step back17 httpbin_url = value.url.rstrip("/") + "/"Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9
lines 18–19why, one step back1819 def inner(*suffix):Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
line 20why, one step back20 return urljoin(httpbin_url, "/".join(suffix))Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9
lines 21–32why, one step back2122 return inner232425@pytest.fixture26def httpbin(httpbin):27 return prepare_url(httpbin)282930@pytest.fixture31def httpbin_secure(httpbin_secure):32 return prepare_url(httpbin_secure)Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba
lines 33–36why, one step back333435@pytest.fixture36def nosan_server(tmp_path_factory):Merge pull request #5990 from mgorny/trustme-test-depIan Stapleton Cordascobefore adoptione77dd8d
lines 37–40why, one step back37 # delay importing until the fixture in order to make it possible38 # to deselect the test via command-line when trustme is not available39 import trustme40Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba
lines 41–43why, one step back41 tmpdir = tmp_path_factory.mktemp("certs")42 ca = trustme.CA()43 # only commonName, no subjectAltNameAdd automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290
line 44why, one step back44 server_cert = ca.issue_cert(common_name="localhost")Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba
lines 45–58why, one step back45 ca_bundle = str(tmpdir / "ca.pem")46 ca.cert_pem.write_to_path(ca_bundle)4748 context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)49 server_cert.configure_cert(context)50 server = HTTPServer(("localhost", 0), SimpleHTTPRequestHandler)51 server.socket = context.wrap_socket(server.socket, server_side=True)52 server_thread = threading.Thread(target=server.serve_forever)53 server_thread.start()5455 yield "localhost", server.server_address[1], ca_bundle5657 server.shutdown()58 server_thread.join()