mitmproxy/examples/test_context.py

24 lines
572 B
Python
Raw Normal View History

2012-07-30 08:58:59 +00:00
import requests
from libpathod import test
2015-05-30 00:03:13 +00:00
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
2015-07-19 16:17:09 +00:00
assert len(r.body) == 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"