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

Test the Python C JSON extension

The C JSON parser was added quite a while ago, but unless you
configure with --enable-shared and have the Python 2/3 development
libraries installed, and the resulting python-ovs module installed,
'make check' won't actually test it.

This patch changes Python-based tests to run from the
$builddir/python directory and makes the tests configurable to use
both JSON backends. There are some unicode failures in the C JSON
extension that I left unfixed in this patch to make it easy to
show run the new tests on broken code. The next patch in this set
works around the issue.

Signed-off-by: Terry Wilson <twilson@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
This commit is contained in:
Terry Wilson
2018-10-09 11:31:32 -05:00
committed by Ben Pfaff
parent 39cc92aa65
commit a7be68a4d7
8 changed files with 199 additions and 82 deletions

View File

@@ -21,10 +21,13 @@ import sys
import six
PARSER_C = 'C'
PARSER_PY = 'PYTHON'
try:
import ovs._json
PARSER = PARSER_C
except ImportError:
pass
PARSER = PARSER_PY
__pychecker__ = 'no-stringiter'
@@ -91,10 +94,9 @@ class Parser(object):
MAX_HEIGHT = 1000
def __new__(cls, *args, **kwargs):
try:
if PARSER == PARSER_C:
return ovs._json.Parser(*args, **kwargs)
except NameError:
return super(Parser, cls).__new__(cls)
return super(Parser, cls).__new__(cls)
def __init__(self, check_trailer=False):
self.check_trailer = check_trailer