summaryrefslogtreecommitdiff
path: root/tests/reset_test.py
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2015-05-19 22:34:01 -0400
committerOleg Pudeyev <oleg@bsdpower.com>2015-09-27 00:36:09 -0400
commit17442ea8a583641c36ed69e09968999ed9f3d0bb (patch)
tree8b8d61425a9d213ea060089c00094acb255114d8 /tests/reset_test.py
parent51d0a8a1f9dad697372ec1af217351d74d39f8ab (diff)
downloadpycurl-17442ea8a583641c36ed69e09968999ed9f3d0bb.tar.gz
Try a more reliable assertion in reset test
Diffstat (limited to 'tests/reset_test.py')
-rw-r--r--tests/reset_test.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/tests/reset_test.py b/tests/reset_test.py
index c12218c..f630814 100644
--- a/tests/reset_test.py
+++ b/tests/reset_test.py
@@ -18,22 +18,23 @@ setup_module, teardown_module = appmanager.setup(('app', 8380))
class ResetTest(unittest.TestCase):
def test_reset(self):
c = pycurl.Curl()
- c.setopt(pycurl.URL, 'http://localhost:8380/success')
- c.reset()
- try:
- c.perform()
- self.fail('Perform worked when it should not have')
- except pycurl.error:
- exc = sys.exc_info()[1]
- code = exc.args[0]
- self.assertEqual(pycurl.E_URL_MALFORMAT, code)
+ c.setopt(pycurl.USERAGENT, 'Phony/42')
+ c.setopt(pycurl.URL, 'http://localhost:8380/header?h=user-agent')
+ sio = util.BytesIO()
+ c.setopt(pycurl.WRITEFUNCTION, sio.write)
+ c.perform()
+ user_agent = sio.getvalue().decode()
+ assert user_agent == 'Phony/42'
- # check that Curl object is usable
- c.setopt(pycurl.URL, 'http://localhost:8380/success')
+ c.reset()
+ c.setopt(pycurl.URL, 'http://localhost:8380/header?h=user-agent')
sio = util.BytesIO()
c.setopt(pycurl.WRITEFUNCTION, sio.write)
c.perform()
- self.assertEqual('success', sio.getvalue().decode())
+ user_agent = sio.getvalue().decode()
+ # we also check that the request succeeded after curl
+ # object has been reset
+ assert user_agent.startswith('PycURL')
# XXX this test was broken when it was test_reset.py
def skip_reset_with_multi(self):