

def urlencode_and_check(self, pf):
    self.curl.setopt(pycurl.URL, 'http://localhost:8380/postfields')
    postfields = urllib_parse.urlencode(pf)
    self.curl.setopt(pycurl.POSTFIELDS, postfields)
    sio = util.StringIO()
    self.curl.setopt(pycurl.WRITEFUNCTION, sio.write)
    self.curl.perform()
    self.assertEqual(200, self.curl.getinfo(pycurl.HTTP_CODE))
    body = sio.getvalue()
    returned_fields = json.loads(body)
    self.assertEqual(pf, returned_fields)

dataset/ETHPy150Open cloudaice/simple-data/misc/virtenv/share/doc/pycurl/tests/post_test.py PostTest.urlencode_and_check/original