diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2013-03-06 00:26:45 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2013-03-06 04:18:26 -0500 |
commit | d5f777ab8254037b0f539ef3e9546adf566e5f82 (patch) | |
tree | b515780f865d0e97b6074768ec17e20d1093e422 /tests/reset_test.py | |
parent | 90fd7f9ff595ede402a21fb6afc62743b96c87e5 (diff) | |
download | pycurl-d5f777ab8254037b0f539ef3e9546adf566e5f82.tar.gz |
Port test_reset.py, which appears to be broken; skip the ported version for now
Diffstat (limited to 'tests/reset_test.py')
-rw-r--r-- | tests/reset_test.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/reset_test.py b/tests/reset_test.py new file mode 100644 index 0000000..66b7108 --- /dev/null +++ b/tests/reset_test.py @@ -0,0 +1,76 @@ +#! /usr/bin/env python +# -*- coding: iso-8859-1 -*- +# vi:ts=4:et + +import sys +import pycurl +import unittest +try: + import urllib.parse as urllib_parse +except ImportError: + import urllib as urllib_parse + +from . import app +from . import runwsgi +from . import util + +setup_module, teardown_module = runwsgi.app_runner_setup((app.app, 8380)) + +class ResetTest(unittest.TestCase): + # XXX this test was broken when it was test_reset.py + def skip_test_reset(self): + outf = util.StringIO() + cm = pycurl.CurlMulti() + + # Set multi handle's options + cm.setopt(pycurl.M_PIPELINING, 1) + + eh = pycurl.Curl() + + for x in range(1, 20): + + eh.setopt(pycurl.WRITEFUNCTION, outf.write) + eh.setopt(pycurl.URL, 'http://localhost:8380/success') + cm.add_handle(eh) + + while 1: + ret, active_handles = cm.perform() + if ret != pycurl.E_CALL_MULTI_PERFORM: + break + + while active_handles: + ret = cm.select(1.0) + if ret == -1: + continue + while 1: + ret, active_handles = cm.perform() + if ret != pycurl.E_CALL_MULTI_PERFORM: + break + + count, good, bad = cm.info_read() + + for h, en, em in bad: + print("Transfer to %s failed with %d, %s\n" % \ + (h.getinfo(pycurl.EFFECTIVE_URL), en, em)) + raise RuntimeError + + for h in good: + httpcode = h.getinfo(pycurl.RESPONSE_CODE) + if httpcode != 200: + print("Transfer to %s failed with code %d\n" %\ + (h.getinfo(pycurl.EFFECTIVE_URL), httpcode)) + raise RuntimeError + + else: + print("Recd %d bytes from %s" % \ + (h.getinfo(pycurl.SIZE_DOWNLOAD), + h.getinfo(pycurl.EFFECTIVE_URL))) + + cm.remove_handle(eh) + eh.reset() + + eh.close() + cm.close() + outf.close() + + pycurl.global_cleanup() |