Skip to content
Myr

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 file

Take 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 back
1try:

Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290

line 2why, one step back
2 from http.server import HTTPServer, SimpleHTTPRequestHandler

Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba

lines 3–4why, one step back
3except ImportError:
4 from BaseHTTPServer import HTTPServer

Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290

line 5why, one step back
5 from SimpleHTTPServer import SimpleHTTPRequestHandler

Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba

lines 6–9why, one step back
6
7import ssl8import threading9

Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9

line 10why, one step back
10import pytest

Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290

line 11why, one step back
11

Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9

lines 12–16why, one step back
12from requests.compat import urljoin
131415def prepare_url(value):16 # Issue #1483: Make sure the URL always has a trailing slash

Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290

line 17why, one step back
17 httpbin_url = value.url.rstrip("/") + "/"

Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9

lines 18–19why, one step back
18
19 def inner(*suffix):

Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290

line 20why, one step back
20 return urljoin(httpbin_url, "/".join(suffix))

Merge pull request #5681 from mateusduboli/5677Ian Stapleton Cordascobefore adoption8c211a9

lines 21–32why, one step back
21
22 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 back
33
3435@pytest.fixture36def nosan_server(tmp_path_factory):

Merge pull request #5990 from mgorny/trustme-test-depIan Stapleton Cordascobefore adoptione77dd8d

lines 37–40why, one step back
37 # delay importing until the fixture in order to make it possible
38 # to deselect the test via command-line when trustme is not available39 import trustme40

Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba

lines 41–43why, one step back
41 tmpdir = tmp_path_factory.mktemp("certs")
42 ca = trustme.CA()43 # only commonName, no subjectAltName

Add automatic code formatting to Requests (#6095)Nate Prewittbefore adoption2a6f290

line 44why, one step back
44 server_cert = ca.issue_cert(common_name="localhost")

Stop abusing pytest-httpbin to test commonName supportQuentin Pradetbefore adoptione253eba

lines 45–58why, one step back
45 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()