From 536d46c3ddb3c0141ce01b83f990c89f6211988f Mon Sep 17 00:00:00 2001
From: "Jason R. Coombs"
Date: Thu, 23 Sep 2021 19:54:33 -0400
Subject: [PATCH] Convert all Python code to Python 3
---
setup.py | 4 +-
suds/__init__.py | 34 ++---
suds/argparser.py | 4 +-
suds/bindings/binding.py | 6 +-
suds/builder.py | 2 +-
suds/cache.py | 4 +-
suds/client.py | 52 ++++----
suds/mx/__init__.py | 5 +-
suds/mx/appender.py | 4 +-
suds/mx/literal.py | 5 +-
suds/mx/typer.py | 4 +-
suds/options.py | 6 +-
suds/plugin.py | 4 +-
suds/properties.py | 26 ++--
suds/sax/__init__.py | 2 +-
suds/sax/attribute.py | 2 +-
suds/sax/date.py | 6 +-
suds/sax/document.py | 2 +-
suds/sax/element.py | 28 ++--
suds/sax/enc.py | 6 +-
suds/sax/parser.py | 16 +--
suds/sax/text.py | 6 +-
suds/servicedefinition.py | 8 +-
suds/serviceproxy.py | 2 +-
suds/store.py | 2 +-
suds/sudsobject.py | 10 +-
suds/transport/__init__.py | 4 +-
suds/transport/http.py | 26 ++--
suds/transport/https.py | 6 +-
suds/transport/options.py | 4 +-
suds/umx/__init__.py | 5 +-
suds/umx/core.py | 2 +-
suds/wsdl.py | 34 +++--
suds/xsd/__init__.py | 4 +-
suds/xsd/deplist.py | 4 +-
suds/xsd/query.py | 2 +-
suds/xsd/schema.py | 12 +-
suds/xsd/sxbase.py | 12 +-
suds/xsd/sxbasic.py | 4 +-
suds/xsd/sxbuiltin.py | 18 +--
tests/external/axis1.py | 192 +++++++++++++-------------
tests/external/axis2.py | 96 ++++++-------
tests/external/jasper.py | 20 +--
tests/external/public.py | 208 ++++++++++++++---------------
tests/external/rhq.py | 126 ++++++++---------
tests/external/saxenc.py | 18 +--
tests/test_argument_parser.py | 2 +-
tests/test_cache.py | 4 +-
tests/test_client_cache.py | 2 +-
tests/test_date_time.py | 2 +-
tests/test_document_store.py | 2 +-
tests/test_input_parameters.py | 2 +-
tests/test_reply_handling.py | 100 +++++++-------
tests/test_request_construction.py | 8 +-
tests/test_suds.py | 6 +-
tests/test_timezone.py | 2 +-
tests/test_transport.py | 38 +++---
tests/test_transport_http.py | 12 +-
58 files changed, 610 insertions(+), 617 deletions(-)
diff --git a/setup.py b/setup.py
index 4b299281..89623a4f 100644
--- a/setup.py
+++ b/setup.py
@@ -60,8 +60,8 @@ def read_python_code(filename):
print("ERROR: Suds library setup script needs to be run from the folder "
"containing it.")
print()
- print("Current folder: %s" % current_folder)
- print("Script folder: %s" % script_folder)
+ print(("Current folder: %s" % current_folder))
+ print(("Script folder: %s" % script_folder))
sys.exit(-2)
# Load the suds library version information directly into this module without
diff --git a/suds/__init__.py b/suds/__init__.py
index 1f8a6d90..908a6c4a 100644
--- a/suds/__init__.py
+++ b/suds/__init__.py
@@ -25,7 +25,7 @@
# Project properties
#
-from version import __build__, __version__
+from .version import __build__, __version__
#
@@ -34,19 +34,19 @@
class MethodNotFound(Exception):
def __init__(self, name):
- Exception.__init__(self, u"Method not found: '%s'" % name)
+ Exception.__init__(self, "Method not found: '%s'" % name)
class PortNotFound(Exception):
def __init__(self, name):
- Exception.__init__(self, u"Port not found: '%s'" % name)
+ Exception.__init__(self, "Port not found: '%s'" % name)
class ServiceNotFound(Exception):
def __init__(self, name):
- Exception.__init__(self, u"Service not found: '%s'" % name)
+ Exception.__init__(self, "Service not found: '%s'" % name)
class TypeNotFound(Exception):
def __init__(self, name):
- Exception.__init__(self, u"Type not found: '%s'" % tostr(name))
+ Exception.__init__(self, "Type not found: '%s'" % tostr(name))
class BuildError(Exception):
msg = """
@@ -71,7 +71,7 @@ def __init__(self, name):
class WebFault(Exception):
def __init__(self, fault, document):
if hasattr(fault, 'faultstring'):
- Exception.__init__(self, u"Server raised fault: '%s'" %
+ Exception.__init__(self, "Server raised fault: '%s'" %
fault.faultstring)
self.fault = fault
self.document = document
@@ -104,7 +104,7 @@ def objid(obj):
def tostr(object, encoding=None):
""" get a unicode safe string representation of an object """
- if isinstance(object, basestring):
+ if isinstance(object, str):
if encoding is None:
return object
else:
@@ -112,7 +112,7 @@ def tostr(object, encoding=None):
if isinstance(object, tuple):
s = ['(']
for item in object:
- if isinstance(item, basestring):
+ if isinstance(item, str):
s.append(item)
else:
s.append(tostr(item))
@@ -122,7 +122,7 @@ def tostr(object, encoding=None):
if isinstance(object, list):
s = ['[']
for item in object:
- if isinstance(item, basestring):
+ if isinstance(item, str):
s.append(item)
else:
s.append(tostr(item))
@@ -131,13 +131,13 @@ def tostr(object, encoding=None):
return ''.join(s)
if isinstance(object, dict):
s = ['{']
- for item in object.items():
- if isinstance(item[0], basestring):
+ for item in list(object.items()):
+ if isinstance(item[0], str):
s.append(item[0])
else:
s.append(tostr(item[0]))
s.append(' = ')
- if isinstance(item[1], basestring):
+ if isinstance(item[1], str):
s.append(item[1])
else:
s.append(tostr(item[1]))
@@ -145,7 +145,7 @@ def tostr(object, encoding=None):
s.append('}')
return ''.join(s)
try:
- return unicode(object)
+ return str(object)
except:
return str(object)
@@ -155,7 +155,7 @@ def tostr(object, encoding=None):
#
if sys.version_info < (3, 0):
- from cStringIO import StringIO as BytesIO
+ from io import StringIO as BytesIO
else:
from io import BytesIO
@@ -165,7 +165,7 @@ class UnicodeMixin(object):
# For Python 3, __str__() and __unicode__() should be identical.
__str__ = lambda x: x.__unicode__()
else:
- __str__ = lambda x: unicode(x).encode('utf-8')
+ __str__ = lambda x: str(x).encode('utf-8')
# Used instead of byte literals because they are not supported on Python
# versions prior to 2.6.
@@ -177,8 +177,8 @@ def byte_str(s='', encoding='utf-8', input_encoding='utf-8', errors='strict'):
strings encoded using the given input encoding.
"""
- assert isinstance(s, basestring)
- if isinstance(s, unicode):
+ assert isinstance(s, str)
+ if isinstance(s, str):
return s.encode(encoding, errors)
if s and encoding != input_encoding:
return s.decode(input_encoding, errors).encode(encoding, errors)
diff --git a/suds/argparser.py b/suds/argparser.py
index 84ac0262..720104e4 100644
--- a/suds/argparser.py
+++ b/suds/argparser.py
@@ -161,7 +161,7 @@ def __check_for_extra_arguments(self, args_required, args_allowed):
return
if self.__kwargs:
- param_name = self.__kwargs.keys()[0]
+ param_name = list(self.__kwargs.keys())[0]
if param_name in self.__params_with_arguments:
msg = "got multiple values for parameter '%s'"
else:
@@ -263,7 +263,7 @@ def __match_ancestry(self, ancestry):
if len(stack) == 1:
return stack[0], ancestry
previous = stack[0]
- for frame, n in zip(stack[1:], xrange(len(ancestry))):
+ for frame, n in zip(stack[1:], range(len(ancestry))):
if frame.id() is not ancestry[n]:
return previous, ancestry[n:]
previous = frame
diff --git a/suds/bindings/binding.py b/suds/bindings/binding.py
index 62f641c2..17d7d19e 100644
--- a/suds/bindings/binding.py
+++ b/suds/bindings/binding.py
@@ -88,7 +88,7 @@ def param_defs(self, method):
@return: A collection of parameter definitions
@rtype: [I{pdef},..]
"""
- raise Exception, 'not implemented'
+ raise Exception('not implemented')
def get_message(self, method, args, kwargs):
"""
@@ -286,7 +286,7 @@ def bodycontent(self, method, args, kwargs):
@return: The XML content for the
@rtype: [L{Element},..]
"""
- raise Exception, 'not implemented'
+ raise Exception('not implemented')
def headercontent(self, method):
"""
@@ -339,7 +339,7 @@ def replycontent(self, method, body):
@return: The body content.
@rtype: [L{Element},...]
"""
- raise Exception, 'not implemented'
+ raise Exception('not implemented')
def body(self, content):
"""
diff --git a/suds/builder.py b/suds/builder.py
index 8ebfb385..42eba0b4 100644
--- a/suds/builder.py
+++ b/suds/builder.py
@@ -34,7 +34,7 @@ def __init__(self, resolver):
def build(self, name):
""" build a an object for the specified typename as defined in the schema """
- if isinstance(name, basestring):
+ if isinstance(name, str):
type = self.resolver.find(name)
if type is None:
raise TypeNotFound(name)
diff --git a/suds/cache.py b/suds/cache.py
index e156d191..fe8e1879 100644
--- a/suds/cache.py
+++ b/suds/cache.py
@@ -28,7 +28,7 @@
import os
from tempfile import gettempdir as tmp
try:
- import cPickle as pickle
+ import pickle as pickle
except Exception:
import pickle
@@ -136,7 +136,7 @@ def setduration(self, **duration):
@type duration: {unit:value}
"""
if len(duration) == 1:
- arg = duration.items()[0]
+ arg = list(duration.items())[0]
if not arg[0] in self.units:
raise Exception('must be: %s' % str(self.units))
self.duration = arg
diff --git a/suds/client.py b/suds/client.py
index d7fda602..4bff1d2d 100644
--- a/suds/client.py
+++ b/suds/client.py
@@ -37,12 +37,12 @@
from suds.transport.https import HttpAuthenticated
from suds.umx.basic import Basic as UmxBasic
from suds.wsdl import Definitions
-import sudsobject
+from . import sudsobject
-from cookielib import CookieJar
+from http.cookiejar import CookieJar
from copy import deepcopy
-import httplib
-from urlparse import urlparse
+import http.client
+from urllib.parse import urlparse
from logging import getLogger
log = getLogger(__name__)
@@ -181,7 +181,7 @@ def __unicode__(self):
if ( suds.__build__ ):
s.append(' build: %s' % suds.__build__)
for sd in self.sd:
- s.append('\n\n%s' % unicode(sd))
+ s.append('\n\n%s' % str(sd))
return ''.join(s)
@@ -223,7 +223,7 @@ def create(self, name):
else:
try:
result = self.builder.build(type)
- except Exception, e:
+ except Exception as e:
log.error("create '%s' failed", name, exc_info=True)
raise BuildError(name, e)
timer.stop()
@@ -312,20 +312,20 @@ def __find(self, name):
"""
service = None
if not len(self.__services):
- raise Exception, 'No services defined'
+ raise Exception('No services defined')
if isinstance(name, int):
try:
service = self.__services[name]
name = service.name
except IndexError:
- raise ServiceNotFound, 'at [%d]' % name
+ raise ServiceNotFound('at [%d]' % name)
else:
for s in self.__services:
if name == s.name:
service = s
break
if service is None:
- raise ServiceNotFound, name
+ raise ServiceNotFound(name)
return PortSelector(self.__client, service.ports, name)
def __ds(self):
@@ -413,13 +413,13 @@ def __find(self, name):
"""
port = None
if not len(self.__ports):
- raise Exception, 'No ports defined: %s' % self.__qn
+ raise Exception('No ports defined: %s' % self.__qn)
if isinstance(name, int):
qn = '%s[%d]' % (self.__qn, name)
try:
port = self.__ports[name]
except IndexError:
- raise PortNotFound, qn
+ raise PortNotFound(qn)
else:
qn = '.'.join((self.__qn, name))
for p in self.__ports:
@@ -427,7 +427,7 @@ def __find(self, name):
port = p
break
if port is None:
- raise PortNotFound, qn
+ raise PortNotFound(qn)
qn = '.'.join((self.__qn, port.name))
return MethodSelector(self.__client, port.methods, qn)
@@ -488,7 +488,7 @@ def __getitem__(self, name):
m = self.__methods.get(name)
if m is None:
qn = '.'.join((self.__qn, name))
- raise MethodNotFound, qn
+ raise MethodNotFound(qn)
return Method(self.__client, m)
@@ -519,10 +519,10 @@ def __call__(self, *args, **kwargs):
client = clientclass(self.client, self.method)
try:
return client.invoke(args, kwargs)
- except WebFault, e:
+ except WebFault as e:
if self.faults():
raise
- return (httplib.INTERNAL_SERVER_ERROR, e)
+ return (http.client.INTERNAL_SERVER_ERROR, e)
def faults(self):
""" get faults option """
@@ -613,7 +613,7 @@ def send(self, soapenv):
reply = self.options.transport.send(request)
timer.stop()
metrics.log.debug('waited %s on server reply', timer)
- except TransportError, e:
+ except TransportError as e:
content = e.fp and e.fp.read() or ''
return self.process_reply(reply=content, status=e.httpcode,
description=tostr(e), original_soapenv=original_soapenv)
@@ -623,12 +623,12 @@ def send(self, soapenv):
def process_reply(self, reply, status=None, description=None,
original_soapenv=None):
if status is None:
- status = httplib.OK
- if status in (httplib.ACCEPTED, httplib.NO_CONTENT):
+ status = http.client.OK
+ if status in (http.client.ACCEPTED, http.client.NO_CONTENT):
return
failed = True
try:
- if status == httplib.OK:
+ if status == http.client.OK:
log.debug('HTTP succeeded:\n%s', reply)
else:
log.debug('HTTP failed - %d - %s:\n%s', status, description,
@@ -657,19 +657,19 @@ def process_reply(self, reply, status=None, description=None,
# An INSTANCE MUST use a "500 Internal Server Error" HTTP status
# code if the response message is a SOAP Fault.
replyroot = None
- if status in (httplib.OK, httplib.INTERNAL_SERVER_ERROR):
+ if status in (http.client.OK, http.client.INTERNAL_SERVER_ERROR):
replyroot = _parse(reply)
plugins.message.parsed(reply=replyroot)
fault = self.get_fault(replyroot)
if fault:
- if status != httplib.INTERNAL_SERVER_ERROR:
+ if status != http.client.INTERNAL_SERVER_ERROR:
log.warn("Web service reported a SOAP processing "
"fault using an unexpected HTTP status code %d. "
"Reporting as an internal server error.", status)
if self.options.faults:
raise WebFault(fault, replyroot)
- return (httplib.INTERNAL_SERVER_ERROR, fault)
- if status != httplib.OK:
+ return (http.client.INTERNAL_SERVER_ERROR, fault)
+ if status != http.client.OK:
if self.options.faults:
# (todo)
# Use a more specific exception class here.
@@ -688,7 +688,7 @@ def process_reply(self, reply, status=None, description=None,
failed = False
if self.options.faults:
return result
- return (httplib.OK, result)
+ return (http.client.OK, result)
finally:
if failed and original_soapenv:
log.error(original_soapenv)
@@ -717,7 +717,7 @@ def headers(self):
@rtype: dict
"""
action = self.method.soap.action
- if isinstance(action, unicode):
+ if isinstance(action, str):
action = action.encode('utf-8')
stock = {'Content-Type':'text/xml; charset=utf-8', 'SOAPAction':action}
result = dict(stock, **self.options.headers)
@@ -742,7 +742,7 @@ class SimClient(SoapClient):
@classmethod
def simulation(cls, kwargs):
""" get whether loopback has been specified in the I{kwargs}. """
- return kwargs.has_key(SimClient.injkey)
+ return SimClient.injkey in kwargs
def invoke(self, args, kwargs):
"""
diff --git a/suds/mx/__init__.py b/suds/mx/__init__.py
index 719e52df..d7f4e4e6 100644
--- a/suds/mx/__init__.py
+++ b/suds/mx/__init__.py
@@ -43,7 +43,7 @@ def __init__(self, tag=None, value=None, **kwargs):
Object.__init__(self)
self.tag = tag
self.value = value
- for k,v in kwargs.items():
+ for k,v in list(kwargs.items()):
setattr(self, k, v)
def __getattr__(self, name):
@@ -52,8 +52,7 @@ def __getattr__(self, name):
v = None
setattr(self, name, v)
else:
- raise AttributeError, \
- 'Content has no attribute %s' % name
+ raise AttributeError('Content has no attribute %s' % name)
else:
v = self.__dict__[name]
return v
diff --git a/suds/mx/appender.py b/suds/mx/appender.py
index f900338f..c122d113 100644
--- a/suds/mx/appender.py
+++ b/suds/mx/appender.py
@@ -208,7 +208,7 @@ def append(self, parent, content):
child = self.node(content)
child.setText(p.get())
parent.append(child)
- for item in p.items():
+ for item in list(p.items()):
cont = Content(tag=item[0], value=item[1])
Appender.append(self, child, cont)
@@ -240,7 +240,7 @@ def append(self, parent, content):
return
child = self.node(content)
parent.append(child)
- for item in d.items():
+ for item in list(d.items()):
cont = Content(tag=item[0], value=item[1])
Appender.append(self, child, cont)
diff --git a/suds/mx/literal.py b/suds/mx/literal.py
index 4b3480f7..25f4c0ad 100644
--- a/suds/mx/literal.py
+++ b/suds/mx/literal.py
@@ -131,9 +131,8 @@ def end(self, parent, content):
if current == content.type:
self.resolver.pop()
else:
- raise Exception, \
- 'content (end) mismatch: top=(%s) cont=(%s)' % \
- (current, content)
+ raise Exception('content (end) mismatch: top=(%s) cont=(%s)' % \
+ (current, content))
def node(self, content):
#
diff --git a/suds/mx/typer.py b/suds/mx/typer.py
index dc16fa53..0378b98d 100644
--- a/suds/mx/typer.py
+++ b/suds/mx/typer.py
@@ -33,10 +33,10 @@ class Typer:
types = {
int : ('int', NS.xsdns),
- long : ('long', NS.xsdns),
+ int : ('long', NS.xsdns),
float : ('float', NS.xsdns),
str : ('string', NS.xsdns),
- unicode : ('string', NS.xsdns),
+ str : ('string', NS.xsdns),
Text : ('string', NS.xsdns),
bool : ('boolean', NS.xsdns),
}
diff --git a/suds/options.py b/suds/options.py
index 2b2d4896..8be480fb 100644
--- a/suds/options.py
+++ b/suds/options.py
@@ -132,9 +132,9 @@ def __init__(self, **kwargs):
Definition('extraArgumentErrors', bool, True),
Definition('faults', bool, True),
Definition('transport', Transport, None, TpLinker()),
- Definition('service', (int, basestring), None),
- Definition('port', (int, basestring), None),
- Definition('location', basestring, None),
+ Definition('service', (int, str), None),
+ Definition('port', (int, str), None),
+ Definition('location', str, None),
Definition('soapheaders', (), ()),
Definition('wsse', Security, None),
Definition('doctor', Doctor, None),
diff --git a/suds/plugin.py b/suds/plugin.py
index 3579f5c4..f4afdf06 100644
--- a/suds/plugin.py
+++ b/suds/plugin.py
@@ -205,7 +205,7 @@ def __getattr__(self, name):
plugins.append(p)
return PluginDomain(ctx, plugins)
else:
- raise Exception, 'plugin domain (%s), invalid' % name
+ raise Exception('plugin domain (%s), invalid' % name)
class PluginDomain:
@@ -252,6 +252,6 @@ def __call__(self, **kwargs):
method = getattr(plugin, self.name, None)
if method and callable(method):
method(ctx)
- except Exception, pe:
+ except Exception as pe:
log.exception(pe)
return ctx
diff --git a/suds/properties.py b/suds/properties.py
index 5907d943..f56f77b7 100644
--- a/suds/properties.py
+++ b/suds/properties.py
@@ -67,23 +67,23 @@ def validate(self, pA, pB):
"""
if pA in pB.links or \
pB in pA.links:
- raise Exception, 'Already linked'
+ raise Exception('Already linked')
dA = pA.domains()
dB = pB.domains()
for d in dA:
if d in dB:
- raise Exception, 'Duplicate domain "%s" found' % d
+ raise Exception('Duplicate domain "%s" found' % d)
for d in dB:
if d in dA:
- raise Exception, 'Duplicate domain "%s" found' % d
- kA = pA.keys()
- kB = pB.keys()
+ raise Exception('Duplicate domain "%s" found' % d)
+ kA = list(pA.keys())
+ kB = list(pB.keys())
for k in kA:
if k in kB:
- raise Exception, 'Duplicate key %s found' % k
+ raise Exception('Duplicate key %s found' % k)
for k in kB:
if k in kA:
- raise Exception, 'Duplicate key %s found' % k
+ raise Exception('Duplicate key %s found' % k)
return self
def teardown(self):
@@ -177,7 +177,7 @@ def validate(self, value):
if len(self.classes) and \
not isinstance(value, self.classes):
msg = '"%s" must be: %s' % (self.name, self.classes)
- raise AttributeError,msg
+ raise AttributeError(msg)
def __repr__(self):
@@ -251,7 +251,7 @@ def update(self, other):
"""
if isinstance(other, Properties):
other = other.defined
- for n,v in other.items():
+ for n,v in list(other.items()):
self.set(n, v)
return self
@@ -372,7 +372,7 @@ def keys(self, history=None):
history = []
history.append(self)
keys = set()
- keys.update(self.definitions.keys())
+ keys.update(list(self.definitions.keys()))
for x in self.links:
if x in history:
continue
@@ -408,7 +408,7 @@ def prime(self):
@return: self
@rtype: L{Properties}
"""
- for d in self.definitions.values():
+ for d in list(self.definitions.values()):
self.defined[d.name] = d.default
return self
@@ -434,10 +434,10 @@ def __get(self, name, *df):
def str(self, history):
s = []
s.append('Definitions:')
- for d in self.definitions.values():
+ for d in list(self.definitions.values()):
s.append('\t%s' % repr(d))
s.append('Content:')
- for d in self.defined.items():
+ for d in list(self.defined.items()):
s.append('\t%s' % str(d))
if self not in history:
history.append(self)
diff --git a/suds/sax/__init__.py b/suds/sax/__init__.py
index be138239..49df1462 100644
--- a/suds/sax/__init__.py
+++ b/suds/sax/__init__.py
@@ -45,7 +45,7 @@ def splitPrefix(name):
@return: A tuple containing the (2) parts of I{name}
@rtype: (I{prefix}, I{name})
"""
- if isinstance(name, basestring) and ':' in name:
+ if isinstance(name, str) and ':' in name:
return tuple(name.split(':', 1))
return None, name
diff --git a/suds/sax/attribute.py b/suds/sax/attribute.py
index 61c5ad7a..8bcf3102 100644
--- a/suds/sax/attribute.py
+++ b/suds/sax/attribute.py
@@ -171,4 +171,4 @@ def __unicode__(self):
v = self.value.escape()
else:
v = self.value
- return u'%s="%s"' % (n, v)
+ return '%s="%s"' % (n, v)
diff --git a/suds/sax/date.py b/suds/sax/date.py
index c5e5e93d..871e38a1 100644
--- a/suds/sax/date.py
+++ b/suds/sax/date.py
@@ -65,7 +65,7 @@ def __init__(self, value):
self.value = value.date()
elif isinstance(value, datetime.date):
self.value = value
- elif isinstance(value, basestring):
+ elif isinstance(value, str):
self.value = self.__parse(value)
else:
raise ValueError("invalid type for Date(): %s" % type(value))
@@ -115,7 +115,7 @@ def __init__(self, value):
"""
if isinstance(value, datetime.datetime):
self.value = value
- elif isinstance(value, basestring):
+ elif isinstance(value, str):
self.value = self.__parse(value)
else:
raise ValueError("invalid type for DateTime(): %s" % type(value))
@@ -173,7 +173,7 @@ def __init__(self, value):
"""
if isinstance(value, datetime.time):
self.value = value
- elif isinstance(value, basestring):
+ elif isinstance(value, str):
self.value = self.__parse(value)
else:
raise ValueError("invalid type for Time(): %s" % type(value))
diff --git a/suds/sax/document.py b/suds/sax/document.py
index 7a4a615d..3b95aaf0 100644
--- a/suds/sax/document.py
+++ b/suds/sax/document.py
@@ -52,7 +52,7 @@ def append(self, node):
the document root element.
@type node: (L{Element}|str|None)
"""
- if isinstance(node, basestring):
+ if isinstance(node, str):
self.__root = Element(node)
return
if isinstance(node, Element):
diff --git a/suds/sax/element.py b/suds/sax/element.py
index 084ea2b0..8cbcb389 100644
--- a/suds/sax/element.py
+++ b/suds/sax/element.py
@@ -158,7 +158,7 @@ def clone(self, parent=None):
root.append(a.clone(self))
for c in self.children:
root.append(c.clone(self))
- for item in self.nsprefixes.items():
+ for item in list(self.nsprefixes.items()):
root.addPrefix(item[0], item[1])
return root
@@ -567,11 +567,11 @@ def findPrefix(self, uri, default=None):
@return: A mapped prefix.
@rtype: basestring
"""
- for item in self.nsprefixes.items():
+ for item in list(self.nsprefixes.items()):
if item[1] == uri:
prefix = item[0]
return prefix
- for item in self.specialprefixes.items():
+ for item in list(self.specialprefixes.items()):
if item[1] == uri:
prefix = item[0]
return prefix
@@ -592,11 +592,11 @@ def findPrefixes(self, uri, match='eq'):
@rtype: [basestring,...]
"""
result = []
- for item in self.nsprefixes.items():
+ for item in list(self.nsprefixes.items()):
if self.matcher[match](item[1], uri):
prefix = item[0]
result.append(prefix)
- for item in self.specialprefixes.items():
+ for item in list(self.specialprefixes.items()):
if self.matcher[match](item[1], uri):
prefix = item[0]
result.append(prefix)
@@ -617,7 +617,7 @@ def promotePrefixes(self):
c.promotePrefixes()
if self.parent is None:
return
- for p,u in self.nsprefixes.items():
+ for p,u in list(self.nsprefixes.items()):
if p in self.parent.nsprefixes:
pu = self.parent.nsprefixes[p]
if pu == u:
@@ -730,7 +730,7 @@ def str(self, indent=0):
result = []
result.append('%s<%s' % (tab, self.qname()))
result.append(self.nsdeclarations())
- for a in [unicode(a) for a in self.attributes]:
+ for a in [str(a) for a in self.attributes]:
result.append(' %s' % a)
if self.isempty():
result.append('/>')
@@ -755,7 +755,7 @@ def plain(self):
result = []
result.append('<%s' % self.qname())
result.append(self.nsdeclarations())
- for a in [unicode(a) for a in self.attributes]:
+ for a in [str(a) for a in self.attributes]:
result.append(' %s' % a)
if self.isempty():
result.append('/>')
@@ -785,7 +785,7 @@ def nsdeclarations(self):
if self.expns is not None:
d = ' xmlns="%s"' % self.expns
s.append(d)
- for item in self.nsprefixes.items():
+ for item in list(self.nsprefixes.items()):
(p,u) = item
if self.parent is not None:
ns = self.parent.resolvePrefix(p)
@@ -884,13 +884,13 @@ def __len__(self):
return len(self.children)
def __getitem__(self, index):
- if isinstance(index, basestring):
+ if isinstance(index, str):
return self.get(index)
if index < len(self.children):
return self.children[index]
def __setitem__(self, index, value):
- if isinstance(index, basestring):
+ if isinstance(index, str):
self.set(index, value)
else:
if index < len(self.children) and isinstance(value, Element):
@@ -927,7 +927,7 @@ def __init__(self, parent):
self.pos = 0
self.children = parent.children
- def next(self):
+ def __next__(self):
"""
Get the next child.
@return: The next child.
@@ -999,7 +999,7 @@ def pset(self, n):
@rtype: set
"""
s = set()
- for ns in n.nsprefixes.items():
+ for ns in list(n.nsprefixes.items()):
if self.permit(ns):
s.add(ns[1])
return s
@@ -1078,7 +1078,7 @@ def refitMappings(self):
for n in self.branch:
n.nsprefixes = {}
n = self.node
- for u, p in self.prefixes.items():
+ for u, p in list(self.prefixes.items()):
n.addPrefix(p, u)
def permit(self, ns):
diff --git a/suds/sax/enc.py b/suds/sax/enc.py
index 8d3219c8..c319fdf8 100644
--- a/suds/sax/enc.py
+++ b/suds/sax/enc.py
@@ -46,7 +46,7 @@ def needsEncoding(self, s):
@return: True if needs encoding.
@rtype: boolean
"""
- if isinstance(s, basestring):
+ if isinstance(s, str):
for c in self.special:
if c in s:
return True
@@ -60,7 +60,7 @@ def encode(self, s):
@return: The encoded string.
@rtype: str
"""
- if isinstance(s, basestring) and self.needsEncoding(s):
+ if isinstance(s, str) and self.needsEncoding(s):
for x in self.encodings:
s = re.sub(x[0], x[1], s)
return s
@@ -73,7 +73,7 @@ def decode(self, s):
@return: The decoded string.
@rtype: str
"""
- if isinstance(s, basestring) and '&' in s:
+ if isinstance(s, str) and '&' in s:
for x in self.decodings:
s = s.replace(x[0], x[1])
return s
diff --git a/suds/sax/parser.py b/suds/sax/parser.py
index a82583a0..02c98e25 100644
--- a/suds/sax/parser.py
+++ b/suds/sax/parser.py
@@ -47,10 +47,10 @@ def __init__(self):
def startElement(self, name, attrs):
top = self.top()
- node = Element(unicode(name))
+ node = Element(str(name))
for a in attrs.getNames():
- n = unicode(a)
- v = unicode(attrs.getValue(a))
+ n = str(a)
+ v = str(attrs.getValue(a))
attribute = Attribute(n,v)
if self.mapPrefix(node, attribute):
continue
@@ -63,19 +63,19 @@ def mapPrefix(self, node, attribute):
skip = False
if attribute.name == 'xmlns':
if len(attribute.value):
- node.expns = unicode(attribute.value)
+ node.expns = str(attribute.value)
skip = True
elif attribute.prefix == 'xmlns':
prefix = attribute.name
- node.nsprefixes[prefix] = unicode(attribute.value)
+ node.nsprefixes[prefix] = str(attribute.value)
skip = True
return skip
def endElement(self, name):
- name = unicode(name)
+ name = str(name)
current = self.top()
if len(current.charbuffer):
- current.text = Text(u''.join(current.charbuffer))
+ current.text = Text(''.join(current.charbuffer))
del current.charbuffer
if len(current):
current.trim()
@@ -85,7 +85,7 @@ def endElement(self, name):
raise Exception('malformed document')
def characters(self, content):
- text = unicode(content)
+ text = str(content)
node = self.top()
node.charbuffer.append(text)
diff --git a/suds/sax/text.py b/suds/sax/text.py
index 985386e4..a5b8c5aa 100644
--- a/suds/sax/text.py
+++ b/suds/sax/text.py
@@ -22,7 +22,7 @@
from suds.sax import *
-class Text(unicode):
+class Text(str):
"""
An XML text object used to represent text content.
@ivar lang: The (optional) language flag.
@@ -75,7 +75,7 @@ def trim(self):
return Text(post, lang=self.lang, escaped=self.escaped)
def __add__(self, other):
- joined = u''.join((self, other))
+ joined = ''.join((self, other))
result = Text(joined, lang=self.lang, escaped=self.escaped)
if isinstance(other, Text):
result.escaped = self.escaped or other.escaped
@@ -112,5 +112,5 @@ def unescape(self):
return self
def __add__(self, other):
- joined = u''.join((self, other))
+ joined = ''.join((self, other))
return Raw(joined, lang=self.lang)
diff --git a/suds/servicedefinition.py b/suds/servicedefinition.py
index 6b0e72f8..f26a6390 100644
--- a/suds/servicedefinition.py
+++ b/suds/servicedefinition.py
@@ -80,7 +80,7 @@ def addports(self):
timer.start()
for port in self.service.ports:
p = self.findport(port)
- for op in port.binding.operations.values():
+ for op in list(port.binding.operations.values()):
m = p[0].method(op.name)
binding = m.binding.input
method = (m.name, binding.param_defs(m))
@@ -138,7 +138,7 @@ def paramtypes(self):
def publictypes(self):
"""Get all public types."""
- for t in self.wsdl.schema.types.values():
+ for t in list(self.wsdl.schema.types.values()):
if t in self.params: continue
if t in self.types: continue
item = (t, t)
@@ -152,7 +152,7 @@ def nextprefix(self):
WSDL document.
"""
used = [ns[0] for ns in self.prefixes]
- used += [ns[0] for ns in self.wsdl.root.nsprefixes.items()]
+ used += [ns[0] for ns in list(self.wsdl.root.nsprefixes.items())]
for n in range(0,1024):
p = 'ns%d'%n
if p not in used:
@@ -235,6 +235,6 @@ def description(self):
def __unicode__(self):
try:
return self.description()
- except Exception, e:
+ except Exception as e:
log.exception(e)
return tostr(e)
diff --git a/suds/serviceproxy.py b/suds/serviceproxy.py
index 278c1896..05708aa9 100644
--- a/suds/serviceproxy.py
+++ b/suds/serviceproxy.py
@@ -70,7 +70,7 @@ def get_enum(self, name):
return self.__client__.factory.create(name)
def __unicode__(self):
- return unicode(self.__client__)
+ return str(self.__client__)
def __getattr__(self, name):
builtin = name.startswith('__') and name.endswith('__')
diff --git a/suds/store.py b/suds/store.py
index e5931aa5..3b805027 100644
--- a/suds/store.py
+++ b/suds/store.py
@@ -566,7 +566,7 @@ def open(self, url):
protocol, location = self.__split(url)
content = self.__find(location)
if protocol == 'suds' and content is None:
- raise Exception, 'location "%s" not in document store' % location
+ raise Exception('location "%s" not in document store' % location)
return content
def __find(self, location):
diff --git a/suds/sudsobject.py b/suds/sudsobject.py
index f96d419b..2f19f563 100644
--- a/suds/sudsobject.py
+++ b/suds/sudsobject.py
@@ -110,7 +110,7 @@ def object(cls, classname=None, dict={}):
inst = subclass()
else:
inst = Object()
- for a in dict.items():
+ for a in list(dict.items()):
setattr(inst, a[0], a[1])
return inst
@@ -146,7 +146,7 @@ def __delattr__(self, name):
self.__keylist__.remove(name)
except:
cls = self.__class__.__name__
- raise AttributeError, "%s has no attribute '%s'" % (cls, name)
+ raise AttributeError("%s has no attribute '%s'" % (cls, name))
def __getitem__(self, name):
if isinstance(name, int):
@@ -179,7 +179,7 @@ def __init__(self, sobject):
self.keylist = self.__keylist(sobject)
self.index = 0
- def next(self):
+ def __next__(self):
keylist = self.keylist
nkeys = len(self.keylist)
while self.index < nkeys:
@@ -271,7 +271,7 @@ def process(self, object, h, n=0, nl=False):
if len(object) == 0:
return ''
return self.print_collection(object, h, n+2)
- if isinstance(object, basestring):
+ if isinstance(object, str):
return '"%s"' % tostr(object)
return '%s' % tostr(object)
@@ -325,7 +325,7 @@ def print_dictionary(self, d, h, n, nl=False):
s.append('\n')
s.append(self.indent(n))
s.append('{')
- for item in d.items():
+ for item in list(d.items()):
s.append('\n')
s.append(self.indent(n+1))
if isinstance(item[1], (list,tuple)):
diff --git a/suds/transport/__init__.py b/suds/transport/__init__.py
index b193aead..31f56a22 100644
--- a/suds/transport/__init__.py
+++ b/suds/transport/__init__.py
@@ -54,7 +54,7 @@ def __init__(self, url, message=None):
self.message = message
def __unicode__(self):
- return u"""\
+ return """\
URL: %s
HEADERS: %s
MESSAGE:
@@ -89,7 +89,7 @@ def __init__(self, code, headers, message):
self.message = message
def __unicode__(self):
- return u"""\
+ return """\
CODE: %s
HEADERS: %s
MESSAGE:
diff --git a/suds/transport/http.py b/suds/transport/http.py
index e3d042be..ef4d0b4a 100644
--- a/suds/transport/http.py
+++ b/suds/transport/http.py
@@ -22,12 +22,12 @@
from suds.transport import *
import base64
-from cookielib import CookieJar
-import httplib
+from http.cookiejar import CookieJar
+import http.client
import socket
import sys
-import urllib2
-from urlparse import urlparse
+import urllib.request, urllib.error, urllib.parse
+from urllib.parse import urlparse
from logging import getLogger
log = getLogger(__name__)
@@ -62,10 +62,10 @@ def open(self, request):
try:
url = self.__get_request_url(request)
log.debug('opening (%s)', url)
- u2request = urllib2.Request(url)
+ u2request = urllib.request.Request(url)
self.proxy = self.options.proxy
return self.u2open(u2request)
- except urllib2.HTTPError, e:
+ except urllib.error.HTTPError as e:
raise TransportError(str(e), e.code, e.fp)
def send(self, request):
@@ -74,7 +74,7 @@ def send(self, request):
msg = request.message
headers = request.headers
try:
- u2request = urllib2.Request(url, msg, headers)
+ u2request = urllib.request.Request(url, msg, headers)
self.addcookies(u2request)
self.proxy = self.options.proxy
request.headers.update(u2request.headers)
@@ -85,10 +85,10 @@ def send(self, request):
headers = fp.headers.dict
else:
headers = fp.headers
- result = Reply(httplib.OK, headers, fp.read())
+ result = Reply(http.client.OK, headers, fp.read())
log.debug('received:\n%s', result)
- except urllib2.HTTPError, e:
- if e.code in (httplib.ACCEPTED, httplib.NO_CONTENT):
+ except urllib.error.HTTPError as e:
+ if e.code in (http.client.ACCEPTED, http.client.NO_CONTENT):
result = None
else:
raise TransportError(e.msg, e.code, e.fp)
@@ -140,7 +140,7 @@ def u2opener(self):
"""
if self.urlopener is None:
- return urllib2.build_opener(*self.u2handlers())
+ return urllib.request.build_opener(*self.u2handlers())
return self.urlopener
def u2handlers(self):
@@ -152,7 +152,7 @@ def u2handlers(self):
"""
handlers = []
- handlers.append(urllib2.ProxyHandler(self.proxy))
+ handlers.append(urllib.request.ProxyHandler(self.proxy))
return handlers
def u2ver(self):
@@ -165,7 +165,7 @@ def u2ver(self):
try:
part = urllib2.__version__.split('.', 1)
return float('.'.join(part))
- except Exception, e:
+ except Exception as e:
log.exception(e)
return 0
diff --git a/suds/transport/https.py b/suds/transport/https.py
index cdff55ab..f1f90513 100644
--- a/suds/transport/https.py
+++ b/suds/transport/https.py
@@ -21,7 +21,7 @@
from suds.transport import *
from suds.transport.http import HttpTransport
-import urllib2
+import urllib.request, urllib.error, urllib.parse
class HttpAuthenticated(HttpTransport):
@@ -55,7 +55,7 @@ def __init__(self, **kwargs):
"""
HttpTransport.__init__(self, **kwargs)
- self.pm = urllib2.HTTPPasswordMgrWithDefaultRealm()
+ self.pm = urllib.request.HTTPPasswordMgrWithDefaultRealm()
def open(self, request):
self.addcredentials(request)
@@ -77,7 +77,7 @@ def credentials(self):
def u2handlers(self):
handlers = HttpTransport.u2handlers(self)
- handlers.append(urllib2.HTTPBasicAuthHandler(self.pm))
+ handlers.append(urllib.request.HTTPBasicAuthHandler(self.pm))
return handlers
diff --git a/suds/transport/options.py b/suds/transport/options.py
index f6a071e0..ccaee82b 100644
--- a/suds/transport/options.py
+++ b/suds/transport/options.py
@@ -53,6 +53,6 @@ def __init__(self, **kwargs):
Definition('proxy', dict, {}),
Definition('timeout', (int,float), 90),
Definition('headers', dict, {}),
- Definition('username', basestring, None),
- Definition('password', basestring, None)]
+ Definition('username', str, None),
+ Definition('password', str, None)]
Skin.__init__(self, domain, definitions, kwargs)
diff --git a/suds/umx/__init__.py b/suds/umx/__init__.py
index ca65cad1..e7d74c35 100644
--- a/suds/umx/__init__.py
+++ b/suds/umx/__init__.py
@@ -40,7 +40,7 @@ def __init__(self, node, **kwargs):
self.node = node
self.data = None
self.text = None
- for k,v in kwargs.items():
+ for k,v in list(kwargs.items()):
setattr(self, k, v)
def __getattr__(self, name):
@@ -49,8 +49,7 @@ def __getattr__(self, name):
v = None
setattr(self, name, v)
else:
- raise AttributeError, \
- 'Content has no attribute %s' % name
+ raise AttributeError('Content has no attribute %s' % name)
else:
v = self.__dict__[name]
return v
diff --git a/suds/umx/core.py b/suds/umx/core.py
index 4db8eaa7..a8192451 100644
--- a/suds/umx/core.py
+++ b/suds/umx/core.py
@@ -95,7 +95,7 @@ def postprocess(self, content):
return None
else:
return Text('', lang=lang)
- if isinstance(content.text, basestring):
+ if isinstance(content.text, str):
return Text(content.text, lang=lang)
else:
return content.text
diff --git a/suds/wsdl.py b/suds/wsdl.py
index 987dbc3f..1cf2ed65 100644
--- a/suds/wsdl.py
+++ b/suds/wsdl.py
@@ -31,8 +31,8 @@
from suds.reader import DocumentReader
import re
-import soaparray
-from urlparse import urljoin
+from . import soaparray
+from urllib.parse import urljoin
from logging import getLogger
log = getLogger(__name__)
@@ -232,7 +232,7 @@ def add_methods(self, service):
for p in service.ports:
binding = p.binding
ptype = p.binding.type
- operations = p.binding.type.operations.values()
+ operations = list(p.binding.type.operations.values())
for name in [op.name for op in operations]:
m = Facade('Method')
m.name = name
@@ -249,8 +249,8 @@ def add_methods(self, service):
def set_wrapped(self):
""" set (wrapped|bare) flag on messages """
- for b in self.bindings.values():
- for op in b.operations.values():
+ for b in list(self.bindings.values()):
+ for op in list(b.operations.values()):
for body in (op.soap.input.body, op.soap.output.body):
body.wrapped = False
if not self.options.unwrap:
@@ -482,7 +482,7 @@ def resolve(self, definitions):
@param definitions: A definitions object.
@type definitions: L{Definitions}
"""
- for op in self.operations.values():
+ for op in list(self.operations.values()):
if op.input is None:
op.input = Message(Element('no-input'), definitions)
else:
@@ -505,7 +505,7 @@ def resolve(self, definitions):
qref = qualify(f.message, self.root, definitions.tns)
msg = definitions.messages.get(qref)
if msg is None:
- raise Exception, "msg '%s', not-found" % f.message
+ raise Exception("msg '%s', not-found" % f.message)
f.message = msg
def operation(self, name):
@@ -519,7 +519,7 @@ def operation(self, name):
"""
try:
return self.operations[name]
- except Exception, e:
+ except Exception as e:
raise MethodNotFound(name)
def __gt__(self, other):
@@ -654,7 +654,7 @@ def resolve(self, definitions):
@type definitions: L{Definitions}
"""
self.resolveport(definitions)
- for op in self.operations.values():
+ for op in list(self.operations.values()):
self.resolvesoapbody(definitions, op)
self.resolveheaders(definitions, op)
self.resolvefaults(definitions, op)
@@ -683,8 +683,7 @@ def resolvesoapbody(self, definitions, op):
"""
ptop = self.type.operation(op.name)
if ptop is None:
- raise Exception, \
- "operation '%s' not defined in portType" % op.name
+ raise Exception("operation '%s' not defined in portType" % op.name)
soap = op.soap
parts = soap.input.body.parts
if len(parts):
@@ -720,15 +719,14 @@ def resolveheaders(self, definitions, op):
ref = qualify(mn, self.root, definitions.tns)
message = definitions.messages.get(ref)
if message is None:
- raise Exception, "message'%s', not-found" % mn
+ raise Exception("message'%s', not-found" % mn)
pn = header.part
for p in message.parts:
if p.name == pn:
header.part = p
break
if pn == header.part:
- raise Exception, \
- "message '%s' has not part named '%s'" % (ref, pn)
+ raise Exception("message '%s' has not part named '%s'" % (ref, pn))
def resolvefaults(self, definitions, op):
"""
@@ -741,8 +739,7 @@ def resolvefaults(self, definitions, op):
"""
ptop = self.type.operation(op.name)
if ptop is None:
- raise Exception, \
- "operation '%s' not defined in portType" % op.name
+ raise Exception("operation '%s' not defined in portType" % op.name)
soap = op.soap
for fault in soap.faults:
for f in ptop.faults:
@@ -751,8 +748,7 @@ def resolvefaults(self, definitions, op):
continue
if hasattr(fault, 'parts'):
continue
- raise Exception, \
- "fault '%s' not defined in portType '%s'" % (fault.name, self.type.name)
+ raise Exception("fault '%s' not defined in portType '%s'" % (fault.name, self.type.name))
def operation(self, name):
"""
@@ -854,7 +850,7 @@ def setlocation(self, url, names=None):
@type names: [str,..]
"""
for p in self.ports:
- for m in p.methods.values():
+ for m in list(p.methods.values()):
if names is None or m.name in names:
m.location = url
diff --git a/suds/xsd/__init__.py b/suds/xsd/__init__.py
index c5d80154..39c2b1d8 100644
--- a/suds/xsd/__init__.py
+++ b/suds/xsd/__init__.py
@@ -59,8 +59,8 @@ def isqref(object):
return (\
isinstance(object, tuple) and \
len(object) == 2 and \
- isinstance(object[0], basestring) and \
- isinstance(object[1], basestring))
+ isinstance(object[0], str) and \
+ isinstance(object[1], str))
class Filter:
diff --git a/suds/xsd/deplist.py b/suds/xsd/deplist.py
index b813f80f..c04393cf 100644
--- a/suds/xsd/deplist.py
+++ b/suds/xsd/deplist.py
@@ -77,7 +77,7 @@ def sort(self):
while len(self.stack):
try:
top = self.top()
- ref = top[1].next()
+ ref = next(top[1])
refd = self.index.get(ref)
if refd is None:
log.debug('"%s" not found, skipped', Repr(ref))
@@ -137,4 +137,4 @@ def pop(self):
x = ('x', ())
L = DepList()
L.add(c, e, d, b, f, a, x)
- print [x[0] for x in L.sort()]
+ print([x[0] for x in L.sort()])
diff --git a/suds/xsd/query.py b/suds/xsd/query.py
index 8f2266b1..40923253 100644
--- a/suds/xsd/query.py
+++ b/suds/xsd/query.py
@@ -54,7 +54,7 @@ def execute(self, schema):
@return: The item matching the search criteria.
@rtype: L{sxbase.SchemaObject}
"""
- raise Exception, 'not-implemented by subclass'
+ raise Exception('not-implemented by subclass')
def filter(self, result):
"""
diff --git a/suds/xsd/schema.py b/suds/xsd/schema.py
index 00e217ff..4f629a81 100644
--- a/suds/xsd/schema.py
+++ b/suds/xsd/schema.py
@@ -104,7 +104,7 @@ def autoblend(self):
@return: self
@rtype: L{SchemaCollection}
"""
- namespaces = self.namespaces.keys()
+ namespaces = list(self.namespaces.keys())
for s in self.children:
for ns in namespaces:
tns = s.root.get('targetNamespace')
@@ -261,27 +261,27 @@ def merge(self, schema):
@returns: self
@rtype: L{Schema}
"""
- for item in schema.attributes.items():
+ for item in list(schema.attributes.items()):
if item[0] in self.attributes:
continue
self.all.append(item[1])
self.attributes[item[0]] = item[1]
- for item in schema.elements.items():
+ for item in list(schema.elements.items()):
if item[0] in self.elements:
continue
self.all.append(item[1])
self.elements[item[0]] = item[1]
- for item in schema.types.items():
+ for item in list(schema.types.items()):
if item[0] in self.types:
continue
self.all.append(item[1])
self.types[item[0]] = item[1]
- for item in schema.groups.items():
+ for item in list(schema.groups.items()):
if item[0] in self.groups:
continue
self.all.append(item[1])
self.groups[item[0]] = item[1]
- for item in schema.agrps.items():
+ for item in list(schema.agrps.items()):
if item[0] in self.agrps:
continue
self.all.append(item[1])
diff --git a/suds/xsd/sxbase.py b/suds/xsd/sxbase.py
index 1ceb8236..fe440c95 100644
--- a/suds/xsd/sxbase.py
+++ b/suds/xsd/sxbase.py
@@ -463,7 +463,7 @@ def description(self):
return ()
def __unicode__(self):
- return unicode(self.str())
+ return str(self.str())
def __repr__(self):
s = []
@@ -520,7 +520,7 @@ def __init__(self, sx):
self.items = sx.rawchildren
self.index = 0
- def next(self):
+ def __next__(self):
"""
Get the I{next} item in the frame's collection.
@return: The next item or None
@@ -571,7 +571,7 @@ def top(self):
else:
raise StopIteration()
- def next(self):
+ def __next__(self):
"""
Get the next item.
@return: A tuple: the next (child, ancestry).
@@ -580,15 +580,15 @@ def next(self):
"""
frame = self.top()
while True:
- result = frame.next()
+ result = next(frame)
if result is None:
self.pop()
- return self.next()
+ return next(self)
if isinstance(result, Content):
ancestry = [f.sx for f in self.stack]
return result, ancestry
self.push(result)
- return self.next()
+ return next(self)
def __iter__(self):
return self
diff --git a/suds/xsd/sxbasic.py b/suds/xsd/sxbasic.py
index f6050885..931abac4 100644
--- a/suds/xsd/sxbasic.py
+++ b/suds/xsd/sxbasic.py
@@ -26,7 +26,7 @@
from suds.sax import Namespace
from suds.transport import TransportError
from suds.reader import DocumentReader
-from urlparse import urljoin
+from urllib.parse import urljoin
from logging import getLogger
log = getLogger(__name__)
@@ -667,7 +667,7 @@ def __applytns(self, root):
root.set(TNS, tns)
else:
if self.schema.tns[1] != tns:
- raise Exception, '%s mismatch' % TNS
+ raise Exception('%s mismatch' % TNS)
def description(self):
diff --git a/suds/xsd/sxbuiltin.py b/suds/xsd/sxbuiltin.py
index 3d2c3dde..111001c1 100644
--- a/suds/xsd/sxbuiltin.py
+++ b/suds/xsd/sxbuiltin.py
@@ -62,7 +62,7 @@ class XBoolean(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring):
+ if isinstance(value, str):
return XBoolean.translation[0].get(value)
else:
if isinstance(value, (bool, int)):
@@ -78,7 +78,7 @@ class XInteger(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring) and len(value):
+ if isinstance(value, str) and len(value):
return int(value)
else:
if isinstance(value, int):
@@ -94,10 +94,10 @@ class XLong(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring) and len(value):
- return long(value)
+ if isinstance(value, str) and len(value):
+ return int(value)
else:
- if isinstance(value, (int, long)):
+ if isinstance(value, int):
return str(value)
return value
@@ -110,7 +110,7 @@ class XFloat(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring) and len(value):
+ if isinstance(value, str) and len(value):
return float(value)
else:
if isinstance(value, float):
@@ -126,7 +126,7 @@ class XDate(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring) and len(value):
+ if isinstance(value, str) and len(value):
return Date(value).value
else:
if isinstance(value, dt.date):
@@ -142,7 +142,7 @@ class XTime(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring) and len(value):
+ if isinstance(value, str) and len(value):
return Time(value).value
else:
if isinstance(value, dt.time):
@@ -158,7 +158,7 @@ class XDateTime(XBuiltin):
@staticmethod
def translate(value, topython=True):
if topython:
- if isinstance(value, basestring) and len(value):
+ if isinstance(value, str) and len(value):
return DateTime(value).value
else:
if isinstance(value, dt.datetime):
diff --git a/tests/external/axis1.py b/tests/external/axis1.py
index 4c74c300..53eeb1d8 100644
--- a/tests/external/axis1.py
+++ b/tests/external/axis1.py
@@ -36,34 +36,34 @@
class MyInitPlugin(InitPlugin):
def initialized(self, context):
- print 'PLUGIN (init): initialized: ctx=%s' % context.__dict__
+ print('PLUGIN (init): initialized: ctx=%s' % context.__dict__)
class MyDocumentPlugin(DocumentPlugin):
def loaded(self, context):
- print 'PLUGIN (document): loaded: ctx=%s' % context.__dict__
+ print('PLUGIN (document): loaded: ctx=%s' % context.__dict__)
def parsed(self, context):
- print 'PLUGIN (document): parsed: ctx=%s' % context.__dict__
+ print('PLUGIN (document): parsed: ctx=%s' % context.__dict__)
class MyMessagePlugin(MessagePlugin):
def marshalled(self, context):
- print 'PLUGIN (message): marshalled: ctx=%s' % context.__dict__
+ print('PLUGIN (message): marshalled: ctx=%s' % context.__dict__)
def sending(self, context):
- print 'PLUGIN (message): sending: ctx=%s' % context.__dict__
+ print('PLUGIN (message): sending: ctx=%s' % context.__dict__)
def received(self, context):
- print 'PLUGIN (message): received: ctx=%s' % context.__dict__
+ print('PLUGIN (message): received: ctx=%s' % context.__dict__)
def parsed(self, context):
- print 'PLUGIN (message): parsed: ctx=%s' % context.__dict__
+ print('PLUGIN (message): parsed: ctx=%s' % context.__dict__)
def unmarshalled(self, context):
- print 'PLUGIN: (massage): unmarshalled: ctx=%s' % context.__dict__
+ print('PLUGIN: (massage): unmarshalled: ctx=%s' % context.__dict__)
myplugins = (
@@ -75,27 +75,27 @@ def unmarshalled(self, context):
def start(url):
global errors
- print '\n________________________________________________________________\n'
- print 'Test @ ( %s )\nerrors = %d\n' % (url, errors)
+ print('\n________________________________________________________________\n')
+ print('Test @ ( %s )\nerrors = %d\n' % (url, errors))
try:
url = 'http://localhost:8081/axis/services/basic-rpc-encoded?wsdl'
start(url)
t = HttpAuthenticated(**credentials)
client = Client(url, transport=t, cache=None, plugins=myplugins)
- print client
+ print(client)
#
# create a name object using the wsdl
#
- print 'create name'
+ print('create name')
name = client.factory.create('ns0:Name')
- name.first = u'jeff'+unichr(1234)
+ name.first = 'jeff'+chr(1234)
name.last = 'ortel'
- print name
+ print(name)
#
# create a phone object using the wsdl
#
- print 'create phone'
+ print('create phone')
phoneA = client.factory.create('ns0:Phone')
phoneA.npa = 410
phoneA.nxx = 555
@@ -119,18 +119,18 @@ def start(url):
# create a person object using the wsdl
#
person = client.factory.create('ns0:Person')
- print '{empty} person=\n%s' % person
+ print('{empty} person=\n%s' % person)
person.name = name
person.age = 43
person.phone = [phoneA,phoneB,phoneC]
person.pets = [dog]
- print 'person=\n%s' % person
+ print('person=\n%s' % person)
#
# add the person (using the webservice)
#
- print 'addPersion()'
+ print('addPersion()')
result = client.service.addPerson(person)
- print '\nreply(\n%s\n)\n' % str(result)
+ print('\nreply(\n%s\n)\n' % str(result))
#
# Async
@@ -159,22 +159,22 @@ def start(url):
ap.age = person.age
ap.phone = person.phone
ap.pets = person.pets
- print 'AnotherPerson\n%s' % ap
+ print('AnotherPerson\n%s' % ap)
#
# update the person's name (using the webservice)
#
- print 'updatePersion()'
+ print('updatePersion()')
result = client.service.updatePerson(ap, newname)
- print '\nreply(\n%s\n)\n' % str(result)
+ print('\nreply(\n%s\n)\n' % str(result))
result = client.service.updatePerson(ap, None)
- print '\nreply(\n%s\n)\n' % str(result)
-except WebFault, f:
+ print('\nreply(\n%s\n)\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
@@ -182,19 +182,19 @@ def start(url):
start(url)
t = HttpAuthenticated(**credentials)
client = Client(url, transport=t, cache=None)
- print client
+ print(client)
#
# create a name object as dict
#
- print 'create name'
+ print('create name')
name = {}
name['first'] = 'Elmer'
name['last'] = 'Fudd'
- print name
+ print(name)
#
# create a phone as dict
#
- print 'create phone'
+ print('create phone')
phoneA = {}
phoneA['npa'] = 410
phoneA['nxx'] = 555
@@ -219,133 +219,133 @@ def start(url):
# create a person as dict
#
person = {}
- print '{empty} person=\n%s' % person
+ print('{empty} person=\n%s' % person)
person['name'] = name
person['age'] = 43
person['phone'] = [phoneA,phoneB, phoneC]
person['pets'] = [dog]
- print 'person=\n%s' % person
+ print('person=\n%s' % person)
#
# add the person (using the webservice)
#
- print 'addPersion()'
+ print('addPersion()')
result = client.service.addPerson(person)
- print '\nreply(\n%s\n)\n' % str(result)
-except WebFault, f:
+ print('\nreply(\n%s\n)\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print "echo(' this is cool ')"
+ print("echo(' this is cool ')")
result = client.service.echo('this is cool')
- print '\nreply( "%s" )\n' % str(result)
- print 'echo(None)'
+ print('\nreply( "%s" )\n' % str(result))
+ print('echo(None)')
result = client.service.echo(None)
- print '\nreply( "%s" )\n' % str(result)
-except WebFault, f:
+ print('\nreply( "%s" )\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print 'hello()'
+ print('hello()')
result = client.service.hello()
- print '\nreply( %s )\n' % str(result)
-except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print 'testVoid()'
+ print('testVoid()')
result = client.service.getVoid()
- print '\nreply( %s )\n' % str(result)
-except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print '** new style arrays **'
+ print('** new style arrays **')
words = ['my', 'dog', 'likes', 'steak']
result = client.service.printList(words)
- print '\nreply( %s )\n' % str(result)
+ print('\nreply( %s )\n' % str(result))
- print '** old style arrays **'
+ print('** old style arrays **')
array = client.factory.create('ArrayOf_xsd_string')
- print 'ArrayOf_xsd_string=\n%s' % array
+ print('ArrayOf_xsd_string=\n%s' % array)
array.item = ['my', 'dog', 'likes', 'steak']
result = client.service.printList(array)
- print '\nreply( %s )\n' % str(result)
-except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
s = 'hello'
for n in range(0, 3):
- print 'getList(%s, %d)' % (s, n)
+ print('getList(%s, %d)' % (s, n))
result = client.service.getList(s, n)
- print '\nreply( %s )\n' % str(result)
+ print('\nreply( %s )\n' % str(result))
assert ( isinstance(result, list) and len(result) == n )
-except WebFault, f:
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print 'testExceptions()'
+ print('testExceptions()')
result = client.service.throwException()
- print '\nreply( %s )\n' % tostr(result)
+ print('\nreply( %s )\n' % tostr(result))
raise Exception('Fault expected and not raised')
-except WebFault, f:
- print f
- print f.fault
-except Exception, e:
+except WebFault as f:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://localhost:8081/axis/services/basic-rpc-encoded?wsdl'
start(url)
client = Client(url, faults=False, **credentials)
- print 'testExceptions()'
+ print('testExceptions()')
result = client.service.throwException()
- print '\nreply( %s )\n' % str(result)
-except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
-print '\nFinished: errors=%d' % errors
+print('\nFinished: errors=%d' % errors)
diff --git a/tests/external/axis2.py b/tests/external/axis2.py
index 0a64a8f7..572b857b 100644
--- a/tests/external/axis2.py
+++ b/tests/external/axis2.py
@@ -24,7 +24,7 @@
errors = 0
url = 'http://localhost:8080/axis2/services/BasicService?wsdl'
-print 'url=%s' % url
+print('url=%s' % url)
#
# create a service client using the wsdl.
@@ -34,25 +34,25 @@
#
# print the service (introspection)
#
-print client
+print(client)
-print 'printList()'
-print client.service.printList(['a','b'])
+print('printList()')
+print(client.service.printList(['a','b']))
#
# create a name object using the wsdl
#
-print 'create name'
+print('create name')
name = client.factory.create('ns2:Name')
-name.first = u'jeff'+unichr(1234)
+name.first = 'jeff'+chr(1234)
name.last = 'ortel'
-print name
+print(name)
#
# create a phone object using the wsdl
#
-print 'create phone'
+print('create phone')
phoneA = client.factory.create('ns2:Phone')
phoneA.npa = 410
phoneA.nxx = 822
@@ -67,10 +67,10 @@
# create a dog
#
dog = client.factory.create('ns2:Dog')
-print dog
+print(dog)
dog.name = 'Chance'
dog.trained = True
-print dog
+print(dog)
#
# create a person object using the wsdl
@@ -80,7 +80,7 @@
#
# inspect empty person
#
-print '{empty} person=\n%s' % person
+print('{empty} person=\n%s' % person)
person.name = name
person.age = None
@@ -92,14 +92,14 @@
#
# inspect person
#
-print 'person=\n%s' % person
+print('person=\n%s' % person)
#
# add the person (using the webservice)
#
-print 'addPersion()'
+print('addPersion()')
result = client.service.addPerson(person)
-print '\nreply(\n%s\n)\n' % result.encode('utf-8')
+print('\nreply(\n%s\n)\n' % result.encode('utf-8'))
#
# create a new name object used to update the person
@@ -111,96 +111,96 @@
#
# update the person's name (using the webservice) and print return person object
#
-print 'updatePersion()'
+print('updatePersion()')
result = client.service.updatePerson(person, newname)
-print '\nreply(\n%s\n)\n' % str(result)
+print('\nreply(\n%s\n)\n' % str(result))
result = client.service.updatePerson(person, None)
-print '\nreply(\n%s\n)\n' % str(result)
+print('\nreply(\n%s\n)\n' % str(result))
#
# invoke the echo service
#
-print 'echo()'
+print('echo()')
client.service.echo(None)
result = client.service.echo('this is cool')
-print '\nreply( %s )\n' % str(result)
+print('\nreply( %s )\n' % str(result))
-print 'echo() with {none}'
+print('echo() with {none}')
result = client.service.echo(None)
-print '\nreply( %s )\n' % str(result)
+print('\nreply( %s )\n' % str(result))
#
# invoke the hello service
#
-print 'hello()'
+print('hello()')
result = client.service.hello()
-print '\nreply( %s )\n' % str(result)
+print('\nreply( %s )\n' % str(result))
#
# invoke the testVoid service
#
try:
- print 'getVoid()'
+ print('getVoid()')
result = client.service.getVoid()
- print '\nreply( %s )\n' % str(result)
-except Exception, e:
- print e
+ print('\nreply( %s )\n' % str(result))
+except Exception as e:
+ print(e)
#
# test list args
#
-print 'getList(list)'
+print('getList(list)')
mylist = ['my', 'dog', 'likes', 'steak']
result = client.service.printList(mylist)
-print '\nreply( %s )\n' % str(result)
+print('\nreply( %s )\n' % str(result))
# tuple
-print 'testListArgs(tuple)'
+print('testListArgs(tuple)')
mylist = ('my', 'dog', 'likes', 'steak')
result = client.service.printList(mylist)
-print '\nreply( %s )\n' % str(result)
+print('\nreply( %s )\n' % str(result))
#
# test list returned
#
for n in range(0, 3):
- print 'getList(str, %d)' % n
+ print('getList(str, %d)' % n)
result = client.service.getList('hello', n)
- print '\nreply( %s )\n' % str(result)
+ print('\nreply( %s )\n' % str(result))
assert ( isinstance(result, list) and len(result) == n )
-print 'addPet()'
+print('addPet()')
dog = client.factory.create('ns2:Dog')
dog.name = 'Chance'
dog.trained = True
-print dog
+print(dog)
try:
result = client.service.addPet(person, dog)
- print '\nreply( %s )\n' % str(result)
-except Exception, e:
- print e
+ print('\nreply( %s )\n' % str(result))
+except Exception as e:
+ print(e)
-print '___________________ E X C E P T I O N S __________________________'
+print('___________________ E X C E P T I O N S __________________________')
#
# test exceptions
#
try:
- print 'throwException() faults=True'
+ print('throwException() faults=True')
result = client.service.throwException()
- print '\nreply( %s )\n' % tostr(result)
-except Exception, e:
- print e
+ print('\nreply( %s )\n' % tostr(result))
+except Exception as e:
+ print(e)
#
# test faults
#
try:
- print 'throwException() faults=False'
+ print('throwException() faults=False')
client.set_options(faults=False)
result = client.service.throwException()
- print '\nreply( %s )\n' % tostr(result)
-except Exception, e:
- print e
+ print('\nreply( %s )\n' % tostr(result))
+except Exception as e:
+ print(e)
-print '\nfinished: errors=%d' % errors
+print('\nfinished: errors=%d' % errors)
diff --git a/tests/external/jasper.py b/tests/external/jasper.py
index fde34d5a..f9015006 100644
--- a/tests/external/jasper.py
+++ b/tests/external/jasper.py
@@ -26,22 +26,22 @@
def start(url):
- print '\n________________________________________________________________\n'
- print 'Test @ ( %s )' % url
+ print('\n________________________________________________________________\n')
+ print('Test @ ( %s )' % url)
try:
url = 'http://localhost:9090/jasperserver-pro/services/repository?wsdl'
start(url)
client = Client(url, username='jeff', password='ortel')
- print client
- print client.service.list('')
-except WebFault, f:
+ print(client)
+ print(client.service.list(''))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
-print '\nFinished: errors = %d' % errors
+print('\nFinished: errors = %d' % errors)
diff --git a/tests/external/public.py b/tests/external/public.py
index c1b96669..7633c3b9 100644
--- a/tests/external/public.py
+++ b/tests/external/public.py
@@ -28,151 +28,151 @@
def start(url):
global errors
- print '\n________________________________________________________________\n'
- print 'Test @ ( %s ) %d' % (url, errors)
+ print('\n________________________________________________________________\n')
+ print('Test @ ( %s ) %d' % (url, errors))
try:
url = 'http://mssoapinterop.org/asmx/simple.asmx?WSDL'
start(url)
client = Client(url)
- print client
+ print(client)
# string
input = "42"
d = dict(inputString=input)
result = client.service.echoString(**d)
- print 'echoString() = %s' % result
+ print('echoString() = %s' % result)
assert result == input
# int
input = 42
result = client.service.echoInteger(input)
- print 'echoInteger() = %s' % result
+ print('echoInteger() = %s' % result)
assert result == input
# float
input = 4.2
result = client.service.echoFloat(input)
- print 'echoFloat() = %s' % result
+ print('echoFloat() = %s' % result)
assert result == input
# suds 0.3.8+
result = client.service.echoIntegerArray([])
- print 'echoIntegerArray() = %s' % result
+ print('echoIntegerArray() = %s' % result)
assert result is None
input = [1,2,3,4]
result = client.service.echoIntegerArray(input)
- print 'echoIntegerArray() = %s' % result
+ print('echoIntegerArray() = %s' % result)
assert result == input
result = client.service.echoIntegerArray(inputIntegerArray=input)
- print 'echoIntegerArray() = %s' % result
+ print('echoIntegerArray() = %s' % result)
assert result == input
-except WebFault, f:
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl'
start(url)
client = Client(url)
- print client
+ print(client)
token = client.service.login('soaptester', 'soaptester')
- print 'token="%s"' % token
+ print('token="%s"' % token)
user = client.service.getUser(token, 'soaptester')
- print 'user="%s"' % user
-except WebFault, f:
+ print('user="%s"' % user)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://jira.atlassian.com/rpc/soap/jirasoapservice-v2?wsdl'
start(url+' ** cloned **')
client = Client(url).clone()
- print '**clone**\n%s' % client
+ print('**clone**\n%s' % client)
token = client.service.login('soaptester', 'soaptester')
- print '**clone** token="%s"' % token
+ print('**clone** token="%s"' % token)
user = client.service.getUser(token, 'soaptester')
- print '**clone** user="%s"' % user
-except WebFault, f:
+ print('**clone** user="%s"' % user)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = ' http://www.boyzoid.com/comp/randomQuote.cfc?wsdl '
start(url)
client = Client(url)
- print client
- print client.service.getQuote(False)
-except WebFault, f:
+ print(client)
+ print(client.service.getQuote(False))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://www.zenfolio.com/zf/api/zfapi.asmx?wsdl'
start(url)
client = Client(url)
- print client
+ print(client)
#client.setport(0)
group = client.factory.create('Group')
- print 'Group:\n%s' % group
- print 'LoadGroupHierarchy("demo")'
+ print('Group:\n%s' % group)
+ print('LoadGroupHierarchy("demo")')
groupHierarchy = client.service.LoadGroupHierarchy("demo")
- print 'result:\n%s' % groupHierarchy
-except WebFault, f:
+ print('result:\n%s' % groupHierarchy)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://cert.synxis.com/interface/ChannelConnect.asmx?WSDL'
start(url)
client = Client(url)
- print client
+ print(client)
#client.setport(0)
tpa = client.factory.create('ns1:TPA_Extensions')
- print client.service.Ping(tpa, "hello")
-except WebFault, f:
+ print(client.service.Ping(tpa, "hello"))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'https://sec.neurofuzz-software.com/paos/genSSHA-SOAP.php?wsdl'
start(url)
client = Client(url)
- print client
- print client.service.genSSHA('hello', 'sha1')
-except WebFault, f:
+ print(client)
+ print(client.service.genSSHA('hello', 'sha1'))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
@@ -180,79 +180,79 @@ def start(url):
start(url)
client = Client(url)
#print client.factory.resolver.schema
- print client
- print 'Logon()'
+ print(client)
+ print('Logon()')
reply = client.service.Logon('testuser','test')
- print reply
-except WebFault, f:
+ print(reply)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://soa.ebrev.info/service.wsdl'
start(url)
client = Client(url)
- print client
-except WebFault, f:
+ print(client)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = 'http://arcweb.esri.com/services/v2/MapImage.wsdl'
start(url)
client = Client(url)
- print client
+ print(client)
env = client.factory.create('ns2:Envelope')
- print env
+ print(env)
options = client.factory.create('ns4:MapImageOptions')
- print options
-except WebFault, f:
+ print(options)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = "http://www.thomas-bayer.com/axis2/services/BLZService?wsdl"
start(url)
client = Client(url)
- print client
+ print(client)
#client.setport(0)
- print client.service.getBank("76251020")
-except WebFault, f:
+ print(client.service.getBank("76251020"))
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
url = "http://arcweb.esri.com/services/v2/RouteFinder.wsdl"
start(url)
client = Client(url)
- print client
-except WebFault, f:
+ print(client)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
timer = metrics.Timer()
@@ -264,19 +264,19 @@ def start(url):
client = Client(url)
#client.setport(0)
timer.stop()
- print 'create client: %s' % timer
+ print('create client: %s' % timer)
timer.start()
s = str(client)
timer.stop()
- print 'str(client): %s' % timer
- print 'client:\n%s' % s
-except WebFault, f:
+ print('str(client): %s' % timer)
+ print('client:\n%s' % s)
+except WebFault as f:
errors += 1
- print f
- print f.fault
-except Exception, e:
+ print(f)
+ print(f.fault)
+except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
-print '\nFinished: errors = %d' % errors
+print('\nFinished: errors = %d' % errors)
diff --git a/tests/external/rhq.py b/tests/external/rhq.py
index c17d578a..e6982fec 100644
--- a/tests/external/rhq.py
+++ b/tests/external/rhq.py
@@ -32,8 +32,8 @@
def start(url):
global errors
- print '\n________________________________________________________________\n'
- print 'Test @ ( %s ) %d' % (url, errors)
+ print('\n________________________________________________________________\n')
+ print('Test @ ( %s ) %d' % (url, errors))
def rhqTest():
@@ -43,7 +43,7 @@ def rhqTest():
url = 'http://localhost.localdomain:7080/rhq-rhq-enterprise-server-ejb3/WebservicesManagerBean?wsdl'
start(url)
client = Client(url)
- print client
+ print(client)
try:
@@ -51,7 +51,7 @@ def rhqTest():
# create name
#
name = client.factory.create('name')
- name.first = u'Jeff'+unichr(1234)
+ name.first = 'Jeff'+chr(1234)
name.last = 'Ortel < Company'
#
# create a phone object using the wsdl
@@ -77,22 +77,22 @@ def rhqTest():
# create a person object using the wsdl
#
person = client.factory.create('person')
- print person
+ print(person)
person.name = name
person.age = 43
person.phone.append(phoneA)
person.phone.append(phoneB)
person.pet.append(dog)
person.pet.append(cat)
- print person
+ print(person)
#
# addPerson()
#
- print 'addPersion()'
+ print('addPersion()')
result = client.service.addPerson(person)
sent = client.last_sent()
rcvd = client.last_received()
- print '\nreply(\n%s\n)\n' % result
+ print('\nreply(\n%s\n)\n' % result)
#
# create a new name object used to update the person
#
@@ -102,110 +102,110 @@ def rhqTest():
#
# update the person's name (using the webservice)
#
- print 'updatePersion()'
+ print('updatePersion()')
result = client.service.updatePerson(person, newname)
- print '\nreply(\n%s\n)\n' % str(result)
+ print('\nreply(\n%s\n)\n' % str(result))
result = client.service.updatePerson(person, None)
- print '\nreply(\n%s\n)\n' % str(result)
- except WebFault, f:
+ print('\nreply(\n%s\n)\n' % str(result))
+ except WebFault as f:
errors += 1
- print f
- print f.fault
- except Exception, e:
+ print(f)
+ print(f.fault)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print "echo('this is cool')"
+ print("echo('this is cool')")
result = client.service.echo('this is cool')
- print '\nreply( %s )\n' % str(result)
- print 'echo(None)'
+ print('\nreply( %s )\n' % str(result))
+ print('echo(None)')
result = client.service.echo(None)
- print '\nreply( %s )\n' % str(result)
- except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+ except WebFault as f:
errors += 1
- print f
- print f.fault
- except Exception, e:
+ print(f)
+ print(f.fault)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print 'hello()'
+ print('hello()')
result = client.service.hello()
- print '\nreply( %s )\n' % str(result)
- except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+ except WebFault as f:
errors += 1
- print f
- print f.fault
- except Exception, e:
+ print(f)
+ print(f.fault)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print 'testVoid()'
+ print('testVoid()')
result = client.service.testVoid()
- print '\nreply( %s )\n' % str(result)
- except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+ except WebFault as f:
errors += 1
- print f
- print f.fault
- except Exception, e:
+ print(f)
+ print(f.fault)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
mylist = ['my', 'dog', 'likes', 'steak']
- print 'testListArgs(%s)' % mylist
+ print('testListArgs(%s)' % mylist)
result = client.service.testListArg(mylist)
- print '\nreply( %s )\n' % str(result)
- except WebFault, f:
+ print('\nreply( %s )\n' % str(result))
+ except WebFault as f:
errors += 1
- print f
- print f.fault
- except Exception, e:
+ print(f)
+ print(f.fault)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
s = 'hello'
for n in range(0, 3):
- print 'getList(%s, %d)' % (s, n)
+ print('getList(%s, %d)' % (s, n))
result = client.service.getList(s, n)
- print '\nreply( %s )\n' % str(result)
+ print('\nreply( %s )\n' % str(result))
if len(result) != n:
errors += 1
- print 'expected (%d), reply (%d)' % (n, len(result))
- except WebFault, f:
+ print('expected (%d), reply (%d)' % (n, len(result)))
+ except WebFault as f:
errors += 1
- print f
- print f.fault
- except Exception, e:
+ print(f)
+ print(f.fault)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
try:
- print 'testExceptions()'
+ print('testExceptions()')
result = client.service.testExceptions()
- print '\nreply( %s )\n' % tostr(result)
+ print('\nreply( %s )\n' % tostr(result))
raise Exception('Fault expected and not raised')
- except WebFault, f:
- print f
- print f.fault
- print f.document
- except Exception, e:
+ except WebFault as f:
+ print(f)
+ print(f.fault)
+ print(f.document)
+ except Exception as e:
errors += 1
- print e
+ print(e)
tb.print_exc()
if __name__ == '__main__':
errors = 0
rhqTest()
- print '\nFinished: errors=%d' % errors
+ print('\nFinished: errors=%d' % errors)
diff --git a/tests/external/saxenc.py b/tests/external/saxenc.py
index 1bb351c4..848e45c3 100644
--- a/tests/external/saxenc.py
+++ b/tests/external/saxenc.py
@@ -26,30 +26,30 @@ def basic():
p = Parser()
d = p.parse(string=xml)
a = d.root()
- print 'A(parsed)=\n%s' % a
+ print('A(parsed)=\n%s' % a)
assert str(a) == xml
b = Element('a')
b.setText('Me && <b>my shadow\'s dog love to \'play\' and sing "la,la,la";')
- print 'B(encoded)=\n%s' % b
+ print('B(encoded)=\n%s' % b)
assert str(b) == xml
- print 'A(text-decoded)=\n%s' % a.getText()
- print 'B(text-decoded)=\n%s' % b.getText()
+ print('A(text-decoded)=\n%s' % a.getText())
+ print('B(text-decoded)=\n%s' % b.getText())
assert a.getText() == b.getText()
- print 'test pruning'
+ print('test pruning')
j = Element('A')
j.set('n', 1)
j.append(Element('B'))
- print j
+ print(j)
j.prune()
- print j
+ print(j)
def cdata():
xml = 'This is my &<tag>]]>'
p = Parser()
d = p.parse(string=xml)
- print d
+ print(d)
a = d.root()
- print a.getText()
+ print(a.getText())
if __name__ == '__main__':
#basic()
diff --git a/tests/test_argument_parser.py b/tests/test_argument_parser.py
index 6afb2050..c7b204e8 100644
--- a/tests/test_argument_parser.py
+++ b/tests/test_argument_parser.py
@@ -28,7 +28,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
diff --git a/tests/test_cache.py b/tests/test_cache.py
index 2044c967..72aa55c4 100644
--- a/tests/test_cache.py
+++ b/tests/test_cache.py
@@ -24,7 +24,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
@@ -54,7 +54,7 @@ def __init__(self, x):
value_p111 = suds.byte_str("pero111")
value_p2 = suds.byte_str("pero2")
value_p22 = suds.byte_str("pero22")
-value_unicode = suds.byte_str(u"€ 的 čćžšđČĆŽŠĐ")
+value_unicode = suds.byte_str("€ 的 čćžšđČĆŽŠĐ")
def test_Cache():
diff --git a/tests/test_client_cache.py b/tests/test_client_cache.py
index 0270bf1c..d93843e6 100644
--- a/tests/test_client_cache.py
+++ b/tests/test_client_cache.py
@@ -23,7 +23,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
diff --git a/tests/test_date_time.py b/tests/test_date_time.py
index dc55a71b..dcc40a8a 100644
--- a/tests/test_date_time.py
+++ b/tests/test_date_time.py
@@ -21,7 +21,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
diff --git a/tests/test_document_store.py b/tests/test_document_store.py
index 64fcf10a..e7854596 100644
--- a/tests/test_document_store.py
+++ b/tests/test_document_store.py
@@ -24,7 +24,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
diff --git a/tests/test_input_parameters.py b/tests/test_input_parameters.py
index a4a6f01b..a841ff21 100644
--- a/tests/test_input_parameters.py
+++ b/tests/test_input_parameters.py
@@ -36,7 +36,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
diff --git a/tests/test_reply_handling.py b/tests/test_reply_handling.py
index 0a53724b..a8e31c2b 100644
--- a/tests/test_reply_handling.py
+++ b/tests/test_reply_handling.py
@@ -24,7 +24,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
@@ -33,7 +33,7 @@
import pytest
-import httplib
+import http.client
import re
import xml.sax
@@ -43,11 +43,11 @@ def test_ACCEPTED_and_NO_CONTENT_status_reported_as_None_with_faults():
f = lambda r, s : client.service.f(__inject={"reply":suds.byte_str(r),
"status":s})
assert f("", None) is None
- pytest.raises(Exception, f, "", httplib.INTERNAL_SERVER_ERROR)
- assert f("", httplib.ACCEPTED) is None
- assert f("", httplib.NO_CONTENT) is None
- assert f("bla-bla", httplib.ACCEPTED) is None
- assert f("bla-bla", httplib.NO_CONTENT) is None
+ pytest.raises(Exception, f, "", http.client.INTERNAL_SERVER_ERROR)
+ assert f("", http.client.ACCEPTED) is None
+ assert f("", http.client.NO_CONTENT) is None
+ assert f("bla-bla", http.client.ACCEPTED) is None
+ assert f("bla-bla", http.client.NO_CONTENT) is None
def test_ACCEPTED_and_NO_CONTENT_status_reported_as_None_without_faults():
@@ -55,11 +55,11 @@ def test_ACCEPTED_and_NO_CONTENT_status_reported_as_None_without_faults():
f = lambda r, s : client.service.f(__inject={"reply":suds.byte_str(r),
"status":s})
assert f("", None) is not None
- assert f("", httplib.INTERNAL_SERVER_ERROR) is not None
- assert f("", httplib.ACCEPTED) is None
- assert f("", httplib.NO_CONTENT) is None
- assert f("bla-bla", httplib.ACCEPTED) is None
- assert f("bla-bla", httplib.NO_CONTENT) is None
+ assert f("", http.client.INTERNAL_SERVER_ERROR) is not None
+ assert f("", http.client.ACCEPTED) is None
+ assert f("", http.client.NO_CONTENT) is None
+ assert f("bla-bla", http.client.ACCEPTED) is None
+ assert f("bla-bla", http.client.NO_CONTENT) is None
def test_badly_formed_reply_XML():
@@ -133,7 +133,7 @@ def test_builtin_data_types(monkeypatch):
"byte":int,
"int":int,
"integer":int,
- "long":long,
+ "long":int,
"negativeInteger":int,
"nonNegativeInteger":int,
"nonPositiveInteger":int,
@@ -141,9 +141,9 @@ def test_builtin_data_types(monkeypatch):
"short":int,
"unsignedByte":int,
"unsignedInt":int,
- "unsignedLong":long,
+ "unsignedLong":int,
"unsignedShort":int}
- for tag, type in integer_type_mapping.items():
+ for tag, type in list(integer_type_mapping.items()):
client = tests.client_from_wsdl(tests.wsdl_output("""\
""" % tag, "value"))
response = client.service.f(__inject=dict(reply=suds.byte_str("""\
@@ -159,7 +159,7 @@ def test_builtin_data_types(monkeypatch):
boolean_mapping = {"0":False, "1":True, "false":False, "true":True}
client = tests.client_from_wsdl(tests.wsdl_output("""\
""", "value"))
- for value, expected_value in boolean_mapping.items():
+ for value, expected_value in list(boolean_mapping.items()):
response = client.service.f(__inject=dict(reply=suds.byte_str("""\
@@ -253,27 +253,27 @@ def test_empty_reply():
f = lambda status=None, description=None : client.service.f(__inject=dict(
reply=suds.byte_str(), status=status, description=description))
status, reason = f()
- assert status == httplib.OK
+ assert status == http.client.OK
assert reason is None
- status, reason = f(httplib.OK)
- assert status == httplib.OK
+ status, reason = f(http.client.OK)
+ assert status == http.client.OK
assert reason is None
- status, reason = f(httplib.INTERNAL_SERVER_ERROR)
- assert status == httplib.INTERNAL_SERVER_ERROR
+ status, reason = f(http.client.INTERNAL_SERVER_ERROR)
+ assert status == http.client.INTERNAL_SERVER_ERROR
assert reason == 'injected reply'
- status, reason = f(httplib.FORBIDDEN)
- assert status == httplib.FORBIDDEN
+ status, reason = f(http.client.FORBIDDEN)
+ assert status == http.client.FORBIDDEN
assert reason == 'injected reply'
- status, reason = f(httplib.FORBIDDEN, "kwack")
- assert status == httplib.FORBIDDEN
+ status, reason = f(http.client.FORBIDDEN, "kwack")
+ assert status == http.client.FORBIDDEN
assert reason == 'kwack'
def test_fault_reply_with_unicode_faultstring(monkeypatch):
monkeypatch.delitem(locals(), "e", False)
- unicode_string = u"€ Jurko Gospodnetić ČĆŽŠĐčćžšđ"
- fault_xml = suds.byte_str(u"""\
+ unicode_string = "€ Jurko Gospodnetić ČĆŽŠĐčćžšđ"
+ fault_xml = suds.byte_str("""\
@@ -286,15 +286,15 @@ def test_fault_reply_with_unicode_faultstring(monkeypatch):
""" % unicode_string)
client = tests.client_from_wsdl(_wsdl__simple, faults=True)
- inject = dict(reply=fault_xml, status=httplib.INTERNAL_SERVER_ERROR)
+ inject = dict(reply=fault_xml, status=http.client.INTERNAL_SERVER_ERROR)
e = pytest.raises(suds.WebFault, client.service.f, __inject=inject).value
assert e.fault.faultstring == unicode_string
assert e.document.__class__ is suds.sax.document.Document
client = tests.client_from_wsdl(_wsdl__simple, faults=False)
status, fault = client.service.f(__inject=dict(reply=fault_xml,
- status=httplib.INTERNAL_SERVER_ERROR))
- assert status == httplib.INTERNAL_SERVER_ERROR
+ status=http.client.INTERNAL_SERVER_ERROR))
+ assert status == http.client.INTERNAL_SERVER_ERROR
assert fault.faultstring == unicode_string
@@ -316,13 +316,13 @@ def test_invalid_fault_namespace(monkeypatch):
""")
client = tests.client_from_wsdl(_wsdl__simple, faults=False)
- inject = dict(reply=fault_xml, status=httplib.OK)
+ inject = dict(reply=fault_xml, status=http.client.OK)
e = pytest.raises(Exception, client.service.f, __inject=inject).value
assert e.__class__ is Exception
assert str(e) == " not mapped to message part"
- for http_status in (httplib.INTERNAL_SERVER_ERROR,
- httplib.PAYMENT_REQUIRED):
+ for http_status in (http.client.INTERNAL_SERVER_ERROR,
+ http.client.PAYMENT_REQUIRED):
status, reason = client.service.f(__inject=dict(reply=fault_xml,
status=http_status, description="trla baba lan"))
assert status == http_status
@@ -360,7 +360,7 @@ def test_reply_error_with_detail_with_fault(monkeypatch):
client = tests.client_from_wsdl(_wsdl__simple, faults=True)
- for http_status in (httplib.OK, httplib.INTERNAL_SERVER_ERROR):
+ for http_status in (http.client.OK, http.client.INTERNAL_SERVER_ERROR):
inject = dict(reply=_fault_reply__with_detail, status=http_status)
e = pytest.raises(suds.WebFault, client.service.f, __inject=inject)
e = e.value
@@ -368,32 +368,32 @@ def test_reply_error_with_detail_with_fault(monkeypatch):
assert e.document.__class__ is suds.sax.document.Document
assert str(e) == "Server raised fault: 'Dummy error.'"
- inject = dict(reply=_fault_reply__with_detail, status=httplib.BAD_REQUEST,
+ inject = dict(reply=_fault_reply__with_detail, status=http.client.BAD_REQUEST,
description="quack-quack")
e = pytest.raises(Exception, client.service.f, __inject=inject).value
assert e.__class__ is Exception
- assert e.args[0][0] == httplib.BAD_REQUEST
+ assert e.args[0][0] == http.client.BAD_REQUEST
assert e.args[0][1] == "quack-quack"
def test_reply_error_with_detail_without_fault():
client = tests.client_from_wsdl(_wsdl__simple, faults=False)
- for http_status in (httplib.OK, httplib.INTERNAL_SERVER_ERROR):
+ for http_status in (http.client.OK, http.client.INTERNAL_SERVER_ERROR):
status, fault = client.service.f(__inject=dict(
reply=_fault_reply__with_detail, status=http_status))
- assert status == httplib.INTERNAL_SERVER_ERROR
+ assert status == http.client.INTERNAL_SERVER_ERROR
_test_fault(fault, True)
status, fault = client.service.f(__inject=dict(
- reply=_fault_reply__with_detail, status=httplib.BAD_REQUEST))
- assert status == httplib.BAD_REQUEST
+ reply=_fault_reply__with_detail, status=http.client.BAD_REQUEST))
+ assert status == http.client.BAD_REQUEST
assert fault == "injected reply"
status, fault = client.service.f(__inject=dict(
- reply=_fault_reply__with_detail, status=httplib.BAD_REQUEST,
+ reply=_fault_reply__with_detail, status=http.client.BAD_REQUEST,
description="haleluja"))
- assert status == httplib.BAD_REQUEST
+ assert status == http.client.BAD_REQUEST
assert fault == "haleluja"
@@ -402,7 +402,7 @@ def test_reply_error_without_detail_with_fault(monkeypatch):
client = tests.client_from_wsdl(_wsdl__simple, faults=True)
- for http_status in (httplib.OK, httplib.INTERNAL_SERVER_ERROR):
+ for http_status in (http.client.OK, http.client.INTERNAL_SERVER_ERROR):
inject = dict(reply=_fault_reply__without_detail, status=http_status)
e = pytest.raises(suds.WebFault, client.service.f, __inject=inject)
e = e.value
@@ -410,27 +410,27 @@ def test_reply_error_without_detail_with_fault(monkeypatch):
assert e.document.__class__ is suds.sax.document.Document
assert str(e) == "Server raised fault: 'Dummy error.'"
- inject = dict(reply=_fault_reply__with_detail, status=httplib.BAD_REQUEST,
+ inject = dict(reply=_fault_reply__with_detail, status=http.client.BAD_REQUEST,
description="quack-quack")
e = pytest.raises(Exception, client.service.f, __inject=inject).value
assert e.__class__ is Exception
- assert e.args[0][0] == httplib.BAD_REQUEST
+ assert e.args[0][0] == http.client.BAD_REQUEST
assert e.args[0][1] == "quack-quack"
def test_reply_error_without_detail_without_fault():
client = tests.client_from_wsdl(_wsdl__simple, faults=False)
- for http_status in (httplib.OK, httplib.INTERNAL_SERVER_ERROR):
+ for http_status in (http.client.OK, http.client.INTERNAL_SERVER_ERROR):
status, fault = client.service.f(__inject=dict(
reply=_fault_reply__without_detail, status=http_status))
- assert status == httplib.INTERNAL_SERVER_ERROR
+ assert status == http.client.INTERNAL_SERVER_ERROR
_test_fault(fault, False)
status, fault = client.service.f(__inject=dict(
- reply=_fault_reply__without_detail, status=httplib.BAD_REQUEST,
+ reply=_fault_reply__without_detail, status=http.client.BAD_REQUEST,
description="kung-fu-fui"))
- assert status == httplib.BAD_REQUEST
+ assert status == http.client.BAD_REQUEST
assert fault == "kung-fu-fui"
@@ -530,7 +530,7 @@ def _attibutes(object):
def _isOutputWrapped(client, method_name):
assert len(client.wsdl.bindings) == 1
- operation = client.wsdl.bindings.values()[0].operations[method_name]
+ operation = list(client.wsdl.bindings.values())[0].operations[method_name]
return operation.soap.output.body.wrapped
diff --git a/tests/test_request_construction.py b/tests/test_request_construction.py
index 94894f71..b5c09ebb 100644
--- a/tests/test_request_construction.py
+++ b/tests/test_request_construction.py
@@ -29,7 +29,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
@@ -588,7 +588,7 @@ def test_missing_parameters():
""")
- assert _compare_request(service.f(u"Pero Ždero"), """\
+ assert _compare_request(service.f("Pero Ždero"), """\
@@ -826,7 +826,7 @@ def test_twice_wrapped_parameter():
# Web service operation calls made with 'invalid' parameters.
def testInvalidParameter(**kwargs):
assert len(kwargs) == 1
- element = kwargs.keys()[0]
+ element = list(kwargs.keys())[0]
expected = "f() got an unexpected keyword argument '%s'" % (element,)
e = pytest.raises(TypeError, client.service.f, **kwargs).value
try:
@@ -947,7 +947,7 @@ def _compare_request(request, expected_xml):
def _isInputWrapped(client, method_name):
assert len(client.wsdl.bindings) == 1
- operation = client.wsdl.bindings.values()[0].operations[method_name]
+ operation = list(client.wsdl.bindings.values())[0].operations[method_name]
return operation.soap.input.body.wrapped
diff --git a/tests/test_suds.py b/tests/test_suds.py
index 614c976d..d6d939f5 100644
--- a/tests/test_suds.py
+++ b/tests/test_suds.py
@@ -27,7 +27,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
@@ -1921,7 +1921,7 @@ def test_simple_wsdl():
assert binding_qname == ("dummy", "my-namespace")
assert binding.__class__ is suds.wsdl.Binding
assert len(binding.operations) == 1
- operation = binding.operations.values()[0]
+ operation = list(binding.operations.values())[0]
input = operation.soap.input.body
output = operation.soap.output.body
assert len(input.parts) == 1
@@ -2060,7 +2060,7 @@ def _element_node_xml(name, min=None, max=None):
def _first_from_dict(d):
"""Returns the first name/value pair from a dictionary or None if empty."""
- for x in d.items():
+ for x in list(d.items()):
return x[0], x[1]
diff --git a/tests/test_timezone.py b/tests/test_timezone.py
index c25db01b..54b68f95 100644
--- a/tests/test_timezone.py
+++ b/tests/test_timezone.py
@@ -21,7 +21,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
diff --git a/tests/test_transport.py b/tests/test_transport.py
index 8cd0454b..3cba4871 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -23,7 +23,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
@@ -36,28 +36,28 @@
@pytest.mark.parametrize("message", (
- u"",
- u"for a bitch it's haaaard...",
- u"I'm here to kick ass,\nand chew bubble gum...\nand I'm all out of gum.",
- u"šuć-muć pa ožeži.. za 100 €\n\nwith multiple\nlines...",
- u"\n\n\n\n\n\n",
- u"中原千军逐蒋"))
+ "",
+ "for a bitch it's haaaard...",
+ "I'm here to kick ass,\nand chew bubble gum...\nand I'm all out of gum.",
+ "šuć-muć pa ožeži.. za 100 €\n\nwith multiple\nlines...",
+ "\n\n\n\n\n\n",
+ "中原千军逐蒋"))
def test_reply_as_string(message):
code = 17
reply = Reply(code, {"aaa":1}, message)
- expected = u"""\
+ expected = """\
CODE: %s
HEADERS: %s
MESSAGE:
%s""" % (code, reply.headers, message)
- assert unicode(reply) == expected
+ assert str(reply) == expected
if sys.version_info < (3, 0):
assert str(reply) == expected.encode("utf-8")
@pytest.mark.parametrize(("code", "headers", "message"), (
(1, {}, "ola"),
- (2, {"semper":"fi"}, u"中原千军逐蒋\n城楼万众检阅")))
+ (2, {"semper":"fi"}, "中原千军逐蒋\n城楼万众检阅")))
def test_reply_constructor(code, headers, message):
reply = Reply(code, headers, message)
assert reply.code == code
@@ -66,28 +66,28 @@ def test_reply_constructor(code, headers, message):
@pytest.mark.parametrize("message", (
- u"",
- u"for a bitch it's haaaard...",
- u"I'm here to kick ass,\nand chew bubble gum...\nand I'm all out of gum.",
- u"šuć-muć pa ožeži.. za 100 €\n\nwith multiple\nlines...",
- u"\n\n\n\n\n\n",
- u"中原千军逐蒋"))
+ "",
+ "for a bitch it's haaaard...",
+ "I'm here to kick ass,\nand chew bubble gum...\nand I'm all out of gum.",
+ "šuć-muć pa ožeži.. za 100 €\n\nwith multiple\nlines...",
+ "\n\n\n\n\n\n",
+ "中原千军逐蒋"))
def test_request_as_string(message):
request = Request("my url", message)
request.headers["aaa"] = 1
- expected = u"""\
+ expected = """\
URL: my url
HEADERS: %s
MESSAGE:
%s""" % (request.headers, message)
- assert unicode(request) == expected
+ assert str(request) == expected
if sys.version_info < (3, 0):
assert str(request) == expected.encode("utf-8")
@pytest.mark.parametrize(("url", "message"), (
("for a bitch it's haaaard...", "it's hard out here..."),
- (u"中原千军逐蒋", u"城楼万众检阅")))
+ ("中原千军逐蒋", "城楼万众检阅")))
def test_request_constructor(url, message):
request = Request(url, message)
assert request.url == url
diff --git a/tests/test_transport_http.py b/tests/test_transport_http.py
index 1502b0d8..f7d182ae 100644
--- a/tests/test_transport_http.py
+++ b/tests/test_transport_http.py
@@ -23,7 +23,7 @@
"""
if __name__ == "__main__":
- import __init__
+ from . import __init__
__init__.runUsingPyTest(globals())
@@ -36,7 +36,7 @@
import base64
import sys
-import urllib2
+import urllib.request, urllib.error, urllib.parse
class MyException(Exception):
@@ -222,7 +222,7 @@ def settimeout(self, *args, **kwargs):
url = "http://%s:%s/svc" % (host, port)
store = suds.store.DocumentStore(wsdl=_wsdl_with_input_data(url))
client = suds.client.Client("suds://wsdl", cache=None, documentStore=store)
- data = u"Дмитровский район"
+ data = "Дмитровский район"
pytest.raises(MyException, client.service.f, data)
assert data.encode("utf-8") in mocker.sentData
@@ -237,7 +237,7 @@ def test_sending_non_ascii_location():
class MockURLOpener:
def open(self, request, timeout=None):
raise MyException
- url = u"http://Дмитровский-район-152312306:9999/svc"
+ url = "http://Дмитровский-район-152312306:9999/svc"
transport = suds.transport.http.HttpTransport()
transport.urlopener = MockURLOpener()
store = suds.store.DocumentStore(wsdl=_wsdl_with_no_input_data(url))
@@ -331,7 +331,7 @@ def _wsdl_with_input_data(url):
Externally specified URL is used as the web service location.
"""
- return suds.byte_str(u"""\
+ return suds.byte_str("""\