init: zero-dep dns-over-https resolver

This commit is contained in:
ImSavsis 2026-07-19 20:36:56 +05:00
commit 7348f9b0dd
18 changed files with 589 additions and 0 deletions

28
tests/test_patch.py Normal file
View file

@ -0,0 +1,28 @@
import socket
from pydoh.patch import patch_socket, unpatch_socket
def test_patch_and_unpatch_restores_original():
original = socket.getaddrinfo
patch_socket()
assert socket.getaddrinfo is not original
unpatch_socket()
assert socket.getaddrinfo is original
def test_patch_is_idempotent():
patch_socket()
patched = socket.getaddrinfo
patch_socket()
assert socket.getaddrinfo is patched
unpatch_socket()
def test_ip_literal_bypasses_doh():
patch_socket()
try:
result = socket.getaddrinfo("127.0.0.1", 80)
assert result
finally:
unpatch_socket()