1#! /usr/bin/env python 2# -*- coding: utf-8 -*- 3# vi:ts=4:et 4 5from . import localhost 6import unittest 7import pycurl 8 9from . import appmanager 10from . import util 11 12setup_module, teardown_module = appmanager.setup(('app', 8380)) 13 14class UserAgentStringTest(unittest.TestCase): 15 def setUp(self): 16 self.curl = util.DefaultCurl() 17 18 def tearDown(self): 19 self.curl.close() 20 21 def test_pycurl_user_agent_string(self): 22 self.curl.setopt(pycurl.URL, 'http://%s:8380/header?h=user-agent' % localhost) 23 sio = util.BytesIO() 24 self.curl.setopt(pycurl.WRITEFUNCTION, sio.write) 25 self.curl.perform() 26 user_agent = sio.getvalue().decode() 27 assert user_agent.startswith('PycURL/') 28 assert 'libcurl/' in user_agent, 'User agent did not include libcurl/: %s' % user_agent 29