def test_toxml(): weixinhandler = Weixin(token='weixin-token') dic1 = {"name": "cloudaice", "age": 23} xml = weixinhandler._toxml(dic1) root = ET.fromstring("<xml>" + xml + "</xml>") params = dict() for elem in root: params[elem.tag] = elem.text if "age" in params: params["age"] = int(params["age"]) assert_equal(params, dic1)