mitmproxy/.sources/examples_context.py

23 lines
574 B
Python
Raw Normal View History

2012-07-30 08:58:59 +00:00
import requests
from libpathod import test
2012-08-23 00:37:02 +00:00
def test_simple():
2012-07-30 08:58:59 +00:00
"""
2012-08-23 00:37:02 +00:00
Testing the requests module with
2012-07-30 08:58:59 +00:00
a pathod context manager.
"""
2012-08-23 00:37:02 +00:00
# Start pathod in a separate thread
with test.Daemon() as d:
# Get a URL for a pathod spec
url = d.p("200:b@100")
# ... and request it
r = requests.put(url)
2012-07-30 08:58:59 +00:00
2012-08-23 00:37:02 +00:00
# Check the returned data
assert r.status_code == 200
assert len(r.content) == 100
2012-07-30 08:58:59 +00:00
2012-08-23 00:37:02 +00:00
# Check pathod's internal log
log = d.last_log()["request"]
assert log["method"] == "PUT"