Fix unicode issues in test cases for Py3+ introduced by issue #150.
This commit is contained in:
parent
3acc7d0914
commit
859822ff05
2 changed files with 12 additions and 2 deletions
|
@ -10,6 +10,10 @@ from sleekxmpp.xmlstream import ET
|
||||||
import base64
|
import base64
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info > (3, 0):
|
||||||
|
unicode = str
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -152,7 +156,7 @@ class rpctime(object):
|
||||||
|
|
||||||
def __init__(self,data=None):
|
def __init__(self,data=None):
|
||||||
#assume string data is in iso format YYYYMMDDTHH:MM:SS
|
#assume string data is in iso format YYYYMMDDTHH:MM:SS
|
||||||
if type(data) is str:
|
if type(data) in (str, unicode):
|
||||||
self.timestamp = time.strptime(data,"%Y%m%dT%H:%M:%S")
|
self.timestamp = time.strptime(data,"%Y%m%dT%H:%M:%S")
|
||||||
elif type(data) is time.struct_time:
|
elif type(data) is time.struct_time:
|
||||||
self.timestamp = data
|
self.timestamp = data
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
See the file LICENSE for copying permission.
|
See the file LICENSE for copying permission.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
import sys
|
||||||
|
|
||||||
from sleekxmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, \
|
from sleekxmpp.plugins.xep_0009.stanza.RPC import RPCQuery, MethodCall, \
|
||||||
MethodResponse
|
MethodResponse
|
||||||
|
@ -21,6 +24,9 @@ from sleekxmpp.xmlstream.tostring import tostring
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info > (3, 0):
|
||||||
|
unicode = str
|
||||||
|
|
||||||
|
|
||||||
class TestJabberRPC(SleekTest):
|
class TestJabberRPC(SleekTest):
|
||||||
|
|
||||||
|
@ -117,7 +123,7 @@ class TestJabberRPC(SleekTest):
|
||||||
"XML to string conversion")
|
"XML to string conversion")
|
||||||
|
|
||||||
def testConvertUnicodeString(self):
|
def testConvertUnicodeString(self):
|
||||||
params = [u"おはよう"]
|
params = ["おはよう"]
|
||||||
params_xml = py2xml(*params)
|
params_xml = py2xml(*params)
|
||||||
expected_xml = self.parse_xml("""
|
expected_xml = self.parse_xml("""
|
||||||
<params xmlns="jabber:iq:rpc">
|
<params xmlns="jabber:iq:rpc">
|
||||||
|
|
Loading…
Reference in a new issue