Home / File/ conftest.py — requests Source File

conftest.py — requests Source File

Architecture documentation for conftest.py, a python file in the requests codebase. 8 imports, 0 dependents.

File python CoreAPI VerbHandlers 8 imports 6 functions

Entity Profile

Dependency Diagram

graph LR
  e696bd14_8c3a_2ed9_0573_afe778384f9e["conftest.py"]
  e0123d2c_ad44_06e1_4fdc_6deb7b88f8f9["http.server"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> e0123d2c_ad44_06e1_4fdc_6deb7b88f8f9
  5418d91f_e3cd_f33f_7649_391cf16611e3["BaseHTTPServer"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> 5418d91f_e3cd_f33f_7649_391cf16611e3
  6644d91e_4e36_b1be_77c3_9c076e1ffdff["SimpleHTTPServer"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> 6644d91e_4e36_b1be_77c3_9c076e1ffdff
  d4c9b75a_57ea_9b07_1986_5bd0fc134387["ssl"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> d4c9b75a_57ea_9b07_1986_5bd0fc134387
  d04f5b22_a751_5438_e937_aa8b0666d15e["threading"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> d04f5b22_a751_5438_e937_aa8b0666d15e
  b820826b_04e7_9e1b_bbf6_b336eaff9a23["pytest"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> b820826b_04e7_9e1b_bbf6_b336eaff9a23
  a3acf0a1_ed03_6384_3bc6_273b8a1f8271["requests.compat"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> a3acf0a1_ed03_6384_3bc6_273b8a1f8271
  e18b8462_858e_24d6_da64_12c74e25afee["trustme"]
  e696bd14_8c3a_2ed9_0573_afe778384f9e --> e18b8462_858e_24d6_da64_12c74e25afee
  style e696bd14_8c3a_2ed9_0573_afe778384f9e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

try:
    from http.server import HTTPServer, SimpleHTTPRequestHandler
except ImportError:
    from BaseHTTPServer import HTTPServer
    from SimpleHTTPServer import SimpleHTTPRequestHandler

import ssl
import threading

import pytest

from requests.compat import urljoin


def prepare_url(value):
    # Issue #1483: Make sure the URL always has a trailing slash
    httpbin_url = value.url.rstrip("/") + "/"

    def inner(*suffix):
        return urljoin(httpbin_url, "/".join(suffix))

    return inner


@pytest.fixture
def httpbin(httpbin):
    return prepare_url(httpbin)


@pytest.fixture
def httpbin_secure(httpbin_secure):
    return prepare_url(httpbin_secure)


@pytest.fixture
def nosan_server(tmp_path_factory):
    # delay importing until the fixture in order to make it possible
    # to deselect the test via command-line when trustme is not available
    import trustme

    tmpdir = tmp_path_factory.mktemp("certs")
    ca = trustme.CA()
    # only commonName, no subjectAltName
    server_cert = ca.issue_cert(common_name="localhost")
    ca_bundle = str(tmpdir / "ca.pem")
    ca.cert_pem.write_to_path(ca_bundle)

    context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
    server_cert.configure_cert(context)
    server = HTTPServer(("localhost", 0), SimpleHTTPRequestHandler)
    server.socket = context.wrap_socket(server.socket, server_side=True)
    server_thread = threading.Thread(target=server.serve_forever)
    server_thread.start()

    yield "localhost", server.server_address[1], ca_bundle

    server.shutdown()
    server_thread.join()

Domain

Subdomains

Dependencies

  • BaseHTTPServer
  • SimpleHTTPServer
  • http.server
  • pytest
  • requests.compat
  • ssl
  • threading
  • trustme

Frequently Asked Questions

What does conftest.py do?
conftest.py is a source file in the requests codebase, written in python. It belongs to the CoreAPI domain, VerbHandlers subdomain.
What functions are defined in conftest.py?
conftest.py defines 6 function(s): BaseHTTPServer, http, httpbin, httpbin_secure, nosan_server, prepare_url.
What does conftest.py depend on?
conftest.py imports 8 module(s): BaseHTTPServer, SimpleHTTPServer, http.server, pytest, requests.compat, ssl, threading, trustme.
Where is conftest.py in the architecture?
conftest.py is located at tests/conftest.py (domain: CoreAPI, subdomain: VerbHandlers, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free