test_testserver.py — requests Source File
Architecture documentation for test_testserver.py, a python file in the requests codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 6cf98a23_4f9c_9f92_66f0_e3af57898d30["test_testserver.py"] 81807cb8_22b9_a4ae_c8b0_91ee147c8a3a["socket"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> 81807cb8_22b9_a4ae_c8b0_91ee147c8a3a d04f5b22_a751_5438_e937_aa8b0666d15e["threading"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> d04f5b22_a751_5438_e937_aa8b0666d15e 17309818_1833_a3e0_d6fe_f97cb9ad6ed1["time"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> 17309818_1833_a3e0_d6fe_f97cb9ad6ed1 b820826b_04e7_9e1b_bbf6_b336eaff9a23["pytest"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> b820826b_04e7_9e1b_bbf6_b336eaff9a23 ce06e854_c78b_b510_291a_dbc144a59aff["requests"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> ce06e854_c78b_b510_291a_dbc144a59aff 1299f040_d82e_36bb_76ee_892d203f2f6a["server.py"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> 1299f040_d82e_36bb_76ee_892d203f2f6a b9ecf8db_ec54_4dfb_626c_b3769674f676["Server"] 6cf98a23_4f9c_9f92_66f0_e3af57898d30 --> b9ecf8db_ec54_4dfb_626c_b3769674f676 style 6cf98a23_4f9c_9f92_66f0_e3af57898d30 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import socket
import threading
import time
import pytest
import requests
from tests.testserver.server import Server
class TestTestServer:
def test_basic(self):
"""messages are sent and received properly"""
question = b"success?"
answer = b"yeah, success"
def handler(sock):
text = sock.recv(1000)
assert text == question
sock.sendall(answer)
with Server(handler) as (host, port):
sock = socket.socket()
sock.connect((host, port))
sock.sendall(question)
text = sock.recv(1000)
assert text == answer
sock.close()
def test_server_closes(self):
"""the server closes when leaving the context manager"""
with Server.basic_response_server() as (host, port):
sock = socket.socket()
sock.connect((host, port))
sock.close()
with pytest.raises(socket.error):
new_sock = socket.socket()
new_sock.connect((host, port))
def test_text_response(self):
"""the text_response_server sends the given text"""
server = Server.text_response_server(
"HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nroflol"
)
with server as (host, port):
r = requests.get(f"http://{host}:{port}")
assert r.status_code == 200
assert r.text == "roflol"
assert r.headers["Content-Length"] == "6"
def test_basic_response(self):
"""the basic response server returns an empty http response"""
with Server.basic_response_server() as (host, port):
r = requests.get(f"http://{host}:{port}")
assert r.status_code == 200
assert r.text == ""
// ... (106 more lines)
Domain
Subdomains
Classes
Source
Frequently Asked Questions
What does test_testserver.py do?
test_testserver.py is a source file in the requests codebase, written in python. It belongs to the CoreAPI domain, SessionLifecycle subdomain.
What does test_testserver.py depend on?
test_testserver.py imports 7 module(s): Server, pytest, requests, server.py, socket, threading, time.
Where is test_testserver.py in the architecture?
test_testserver.py is located at tests/test_testserver.py (domain: CoreAPI, subdomain: SessionLifecycle, directory: tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free