2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-29 15:28:56 +00:00

tests: Fix the two Python XFAIL tests.

OVS has two Python tests that have always failed, for reasons not
understood, since they were added to the tree.  This commit fixes them.

One problem was that Python was assuming that stdout was encoded in ASCII.
Apparently the only way to "fix" this at runtime is to set PYTHONIOENCODING
to utf_8 in the environment, so this change does that.

Second, it appears that Python really doesn't like to print invalid UTF-8,
so this avoids doing that in python/ovs/json.py, instead just printing
the hexadecimal values of the invalid bytes.  For consistency, it makes
the same change to the C version.

Third, the C version of test-ovsdb doesn't check UTF-8 for consistency, it
just sends it blindly to the OVSDB server, but Python does check it and so
it bails out earlier.  This commit changes the Python version of the
"no invalid UTF-8 sequences in strings" to allow for the slight difference
in output that occurs for that reason.

Finally, test-ovsdb.py needs to convert error messages to Unicode
explicitly before printing them in the "parse-atoms" function.  I don't
really understand why, but now it works.
This commit is contained in:
Ben Pfaff
2011-05-13 14:20:10 -07:00
parent 19997ceee0
commit be44585c21
5 changed files with 26 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2010 Nicira Networks
# Copyright (c) 2010, 2011 Nicira Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -114,9 +114,7 @@ def from_string(s):
s = unicode(s, 'utf-8')
except UnicodeDecodeError, e:
seq = ' '.join(["0x%2x" % ord(c) for c in e.object[e.start:e.end]])
raise Error("\"%s\" is not a valid UTF-8 string: "
"invalid UTF-8 sequence %s" % (s, seq),
tag="constraint violation")
return ("not a valid UTF-8 string: invalid UTF-8 sequence %s" % seq)
p = Parser(check_trailer=True)
p.feed(s)
return p.finish()