diff options
author | Rafael H. Schloming <rhs@apache.org> | 2009-12-09 18:08:14 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2009-12-09 18:08:14 +0000 |
commit | 1af1e7bb70a66793b055bf9ec2f9cc49dd1b3859 (patch) | |
tree | ee940af45fd12b7a106462ed63a7775e6e6520ff /python/qpid/tests/parser.py | |
parent | c87bce67ac12ee37f8257efd02ab62fe19336b32 (diff) | |
download | qpid-python-1af1e7bb70a66793b055bf9ec2f9cc49dd1b3859.tar.gz |
split out some of the generic parsing stuff in the address parser, and added a real mimetype parser in anticipation of a fix for QPID-2255
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@888901 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/tests/parser.py')
-rw-r--r-- | python/qpid/tests/parser.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/python/qpid/tests/parser.py b/python/qpid/tests/parser.py new file mode 100644 index 0000000000..a4865cc9fe --- /dev/null +++ b/python/qpid/tests/parser.py @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from qpid.parser import ParseError + +class ParserBase: + + def lex(self, addr, *types): + toks = [t.type for t in self.do_lex(addr) if t.type not in self.EXCLUDE] + assert list(types) == toks, "expected %s, got %s" % (types, toks) + + def valid(self, addr, expected): + got = self.do_parse(addr) + assert expected == got, "expected %s, got %s" % (expected, got) + + def invalid(self, addr, error=None): + try: + p = self.do_parse(addr) + assert False, "invalid address parsed: %s" % p + except ParseError, e: + assert error == str(e), "expected %r, got %r" % (error, str(e)) |