mitmproxy/examples/test_setupall.py
Maximilian Hils 2f670bac99 fix tests, use pytest
We currently test with unparallelized builds,
because there are apparently some race conditions
in the test suite, which I can't trigger locally
but happen on travis.

Squashed commit of the following:

commit 7dceb6dd3a1bdbc39688258bc4dff6eee685a33b
Author: Maximilian Hils <git@maximilianhils.com>
Date:   Mon Sep 21 23:00:24 2015 +0200

    disable parallelized tests

commit fc0c3f12ee9259162e83026851362925d93b69f2
Author: Maximilian Hils <git@maximilianhils.com>
Date:   Mon Sep 21 22:49:19 2015 +0200

    fix tests

commit baba3ca5ef49bdbd7aad14f1bf0626738fa3d21c
Author: Maximilian Hils <git@maximilianhils.com>
Date:   Mon Sep 21 22:28:20 2015 +0200

    fix tests, use py.test
2015-09-21 23:03:45 +02:00

40 lines
870 B
Python

import requests
from libpathod import test
class Test:
"""
Testing the requests module with
a single pathod instance started
for the test suite.
"""
@classmethod
def setup_class(cls):
cls.d = test.Daemon()
@classmethod
def teardown_class(cls):
cls.d.shutdown()
def setup(self):
# Clear the pathod logs between tests
self.d.clear_log()
def test_simple(self):
# Get a URL for a pathod spec
url = self.d.p("200:b@100")
# ... and request it
r = requests.put(url)
# Check the returned data
assert r.status_code == 200
assert len(r.content) == 100
# Check pathod's internal log
log = self.d.last_log()["request"]
assert log["method"] == "PUT"
def test_two(self):
assert not self.d.log()