pyloxi: create inheritance hierarchy
Virtual classes are generated but currently only serve as superclasses.
Somehow this works without topologically sorting the classes.
diff --git a/py_gen/tests/of10.py b/py_gen/tests/of10.py
index c4725e3..818f123 100644
--- a/py_gen/tests/of10.py
+++ b/py_gen/tests/of10.py
@@ -30,6 +30,7 @@
from testutil import add_datafiles_tests
try:
+ import loxi
import loxi.of10 as ofp
from loxi.generic_util import OFReader
except ImportError:
@@ -195,11 +196,11 @@
msg = ofp.message.parse_message(buf)
assert(msg.xid == 0x12345678)
- # Get a list of all message classes
+ # Get a list of all concrete message classes
test_klasses = [x for x in ofp.message.__dict__.values()
if type(x) == type
- and issubclass(x, ofp.message.Message)
- and x != ofp.message.Message]
+ and issubclass(x, ofp.message.message)
+ and hasattr(x, 'pack')]
for klass in test_klasses:
self.assertIsInstance(ofp.message.parse_message(klass(xid=1).pack()), klass)
@@ -228,7 +229,9 @@
mods = [ofp.action,ofp.message,ofp.common]
self.klasses = [klass for mod in mods
for klass in mod.__dict__.values()
- if hasattr(klass, 'show')]
+ if isinstance(klass, type) and
+ issubclass(klass, loxi.OFObject) and
+ hasattr(klass, 'pack')]
self.klasses.sort(key=lambda x: str(x))
def test_serialization(self):
@@ -248,7 +251,7 @@
def test_parse_message(self):
expected_failures = []
for klass in self.klasses:
- if not issubclass(klass, ofp.message.Message):
+ if not issubclass(klass, ofp.message.message):
continue
def fn():
obj = klass(xid=42)
diff --git a/py_gen/tests/of11.py b/py_gen/tests/of11.py
index 07a5437..b30a40c 100644
--- a/py_gen/tests/of11.py
+++ b/py_gen/tests/of11.py
@@ -28,6 +28,7 @@
import unittest
try:
+ import loxi
import loxi.of11 as ofp
except ImportError:
exit("loxi package not found. Try setting PYTHONPATH.")
@@ -65,7 +66,9 @@
mods = [ofp.action,ofp.message,ofp.common]
self.klasses = [klass for mod in mods
for klass in mod.__dict__.values()
- if hasattr(klass, 'show')]
+ if isinstance(klass, type) and
+ issubclass(klass, loxi.OFObject) and
+ hasattr(klass, 'pack')]
self.klasses.sort(key=lambda x: str(x))
def test_serialization(self):
@@ -85,7 +88,7 @@
def test_parse_message(self):
expected_failures = []
for klass in self.klasses:
- if not issubclass(klass, ofp.message.Message):
+ if not issubclass(klass, ofp.message.message):
continue
def fn():
obj = klass(xid=42)
diff --git a/py_gen/tests/of12.py b/py_gen/tests/of12.py
index 98d999b..fcdb0cf 100644
--- a/py_gen/tests/of12.py
+++ b/py_gen/tests/of12.py
@@ -29,6 +29,7 @@
from testutil import add_datafiles_tests
try:
+ import loxi
import loxi.of12 as ofp
except ImportError:
exit("loxi package not found. Try setting PYTHONPATH.")
@@ -74,7 +75,9 @@
mods = [ofp.action,ofp.message,ofp.common,ofp.oxm]
self.klasses = [klass for mod in mods
for klass in mod.__dict__.values()
- if hasattr(klass, 'show')]
+ if isinstance(klass, type) and
+ issubclass(klass, loxi.OFObject) and
+ hasattr(klass, 'pack')]
self.klasses.sort(key=lambda x: str(x))
def test_serialization(self):
@@ -96,7 +99,7 @@
def test_parse_message(self):
expected_failures = []
for klass in self.klasses:
- if not issubclass(klass, ofp.message.Message):
+ if not issubclass(klass, ofp.message.message):
continue
def fn():
obj = klass(xid=42)
diff --git a/py_gen/tests/of13.py b/py_gen/tests/of13.py
index 8c18f41..07b0ef0 100644
--- a/py_gen/tests/of13.py
+++ b/py_gen/tests/of13.py
@@ -30,6 +30,7 @@
from testutil import add_datafiles_tests
try:
+ import loxi
import loxi.of13 as ofp
from loxi.generic_util import OFReader
except ImportError:
@@ -88,7 +89,9 @@
mods = [ofp.action,ofp.message,ofp.common,ofp.oxm]
self.klasses = [klass for mod in mods
for klass in mod.__dict__.values()
- if hasattr(klass, 'show')]
+ if isinstance(klass, type) and
+ issubclass(klass, loxi.OFObject) and
+ hasattr(klass, 'pack')]
self.klasses.sort(key=lambda x: str(x))
def test_serialization(self):
@@ -120,7 +123,7 @@
ofp.message.table_features_stats_request,
]
for klass in self.klasses:
- if not issubclass(klass, ofp.message.Message):
+ if not issubclass(klass, ofp.message.message):
continue
def fn():
obj = klass(xid=42)