summaryrefslogtreecommitdiff
path: root/python/qpid
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-03-19 19:15:11 +0000
committerAlan Conway <aconway@apache.org>2007-03-19 19:15:11 +0000
commit776c3c3a9a37b5ec4f75b40c406aabba55fd30ec (patch)
tree01e4036372f2745f9b6103564fdd8ea4b6f8aa11 /python/qpid
parent1d74de398b1edaf6c1eb7a69219a24ceb3f107e8 (diff)
downloadqpid-python-776c3c3a9a37b5ec4f75b40c406aabba55fd30ec.tar.gz
* python/testlib.py: -s (spec) option now also takes abbreviations "0-8" and "0-9"
to load default 0-8 or 0-9 XML respectively. Default is still 0-8. Merged revisions 501586 via svnmerge from https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9 ........ r501586 | rhs | 2007-01-30 16:44:41 -0500 (Tue, 30 Jan 2007) | 1 line updated python spec parse to load from multiple files, changed default specs to include errata ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@520050 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid')
-rw-r--r--python/qpid/spec.py88
-rw-r--r--python/qpid/testlib.py26
2 files changed, 67 insertions, 47 deletions
diff --git a/python/qpid/spec.py b/python/qpid/spec.py
index 3e8b9e37bd..ffd7b5a454 100644
--- a/python/qpid/spec.py
+++ b/python/qpid/spec.py
@@ -79,11 +79,12 @@ class Spec(Metadata):
PRINT=["major", "minor", "file"]
- def __init__(self, major, minor, file):
+ def __init__(self, major, minor, file, errata):
Metadata.__init__(self)
self.major = major
self.minor = minor
self.file = file
+ self.errata = errata
self.constants = SpecContainer()
self.classes = SpecContainer()
# methods indexed by classname_methname
@@ -267,43 +268,56 @@ def load_fields(nd, l, domains):
type = domains[type]
l.add(Field(pythonize(f_nd["@name"]), f_nd.index(), type, get_docs(f_nd)))
-def load(specfile):
+def load(specfile, *errata):
doc = xmlutil.parse(specfile)
- root = doc["amqp"][0]
- spec = Spec(int(root["@major"]), int(root["@minor"]), specfile)
-
- # constants
- for nd in root["constant"]:
- const = Constant(spec, pythonize(nd["@name"]), int(nd["@value"]),
- nd.get("@class"), get_docs(nd))
- spec.constants.add(const)
-
- # domains are typedefs
- domains = {}
- for nd in root["domain"]:
- domains[nd["@name"]] = nd["@type"]
-
- # classes
- for c_nd in root["class"]:
- klass = Class(spec, pythonize(c_nd["@name"]), int(c_nd["@index"]),
- c_nd["@handler"], get_docs(c_nd))
- load_fields(c_nd, klass.fields, domains)
- for m_nd in c_nd["method"]:
- meth = Method(klass, pythonize(m_nd["@name"]),
- int(m_nd["@index"]),
- m_nd.get_bool("@content", False),
- [pythonize(nd["@name"]) for nd in m_nd["response"]],
- m_nd.get_bool("@synchronous", False),
- m_nd.text,
- get_docs(m_nd))
- load_fields(m_nd, meth.fields, domains)
- klass.methods.add(meth)
- # resolve the responses
- for m in klass.methods:
- m.responses = [klass.methods.byname[r] for r in m.responses]
- for resp in m.responses:
- resp.response = True
- spec.classes.add(klass)
+ spec_root = doc["amqp"][0]
+ spec = Spec(int(spec_root["@major"]), int(spec_root["@minor"]), specfile, errata)
+
+ for root in [spec_root] + map(lambda x: xmlutil.parse(x)["amqp"][0], errata):
+ # constants
+ for nd in root["constant"]:
+ const = Constant(spec, pythonize(nd["@name"]), int(nd["@value"]),
+ nd.get("@class"), get_docs(nd))
+ spec.constants.add(const)
+
+ # domains are typedefs
+ domains = {}
+ for nd in root["domain"]:
+ domains[nd["@name"]] = nd["@type"]
+
+ # classes
+ for c_nd in root["class"]:
+ cname = pythonize(c_nd["@name"])
+ if root == spec_root:
+ klass = Class(spec, cname, int(c_nd["@index"]), c_nd["@handler"],
+ get_docs(c_nd))
+ spec.classes.add(klass)
+ else:
+ klass = spec.classes.byname[cname]
+
+ added_methods = []
+ load_fields(c_nd, klass.fields, domains)
+ for m_nd in c_nd["method"]:
+ mname = pythonize(m_nd["@name"])
+ if root == spec_root:
+ meth = Method(klass, mname,
+ int(m_nd["@index"]),
+ m_nd.get_bool("@content", False),
+ [pythonize(nd["@name"]) for nd in m_nd["response"]],
+ m_nd.get_bool("@synchronous", False),
+ m_nd.text,
+ get_docs(m_nd))
+ klass.methods.add(meth)
+ added_methods.append(meth)
+ else:
+ meth = klass.methods.byname[mname]
+ load_fields(m_nd, meth.fields, domains)
+ # resolve the responses
+ for m in added_methods:
+ m.responses = [klass.methods.byname[r] for r in m.responses]
+ for resp in m.responses:
+ resp.response = True
+
spec.post_load()
return spec
diff --git a/python/qpid/testlib.py b/python/qpid/testlib.py
index eebb860104..708ebcdcb9 100644
--- a/python/qpid/testlib.py
+++ b/python/qpid/testlib.py
@@ -57,7 +57,9 @@ run-tests [options] [test*]
The name of a test is package.module.ClassName.testMethod
Options:
-?/-h/--help : this message
- -s/--spec <spec.xml> : file containing amqp XML spec
+ -s/--spec <spec.xml> : URL of AMQP XML specification or one of these abbreviations:
+ 0-8 - use the default 0-8 specification.
+ 0-9 - use the default 0-9 specification.
-b/--broker [<user>[/<password>]@]<host>[:<port>] : broker to connect to
-v/--verbose : verbose - lists tests as they are run.
-d/--debug : enable debug logging.
@@ -77,13 +79,6 @@ Options:
self.user = default(self.user, "guest")
self.password = default(self.password, "guest")
- def __init__(self):
- # Defaults
- self.setBroker("localhost")
- self.specfile = "../specs/amqp.0-8.xml"
- self.verbose = 1
- self.ignore = []
-
def ignoreFile(self, filename):
f = file(filename)
for line in f.readlines(): self.ignore.append(line.strip())
@@ -95,6 +90,12 @@ Options:
return self.spec.major==8 and self.spec.minor==0
def _parseargs(self, args):
+ # Defaults
+ self.setBroker("localhost")
+ self.verbose = 1
+ self.ignore = []
+ self.specfile = "0-8"
+ self.errata = []
try:
opts, self.tests = getopt(args, "s:b:h?dvi:I:", ["help", "spec", "server", "verbose", "ignore", "ignore-file"])
except GetoptError, e:
@@ -107,8 +108,13 @@ Options:
if opt in ("-d", "--debug"): logging.basicConfig(level=logging.DEBUG)
if opt in ("-i", "--ignore"): self.ignore.append(value)
if opt in ("-I", "--ignore-file"): self.ignoreFile(value)
-
- self.spec = qpid.spec.load(self.specfile)
+ if (self.specfile == "0-8"):
+ self.specfile = "../specs/amqp.0-8.xml"
+ if (self.specfile == "0-9"):
+ self.specfile = "../specs/amqp.0-9.xml"
+ self.errata = ["../specs/amqp-errata.0-9.xml"]
+ print "Using specification from:", self.specfile
+ self.spec = qpid.spec.load(self.specfile, *self.errata)
if len(self.tests) == 0:
if self.use08spec():
testdir="tests_0-8"