summaryrefslogtreecommitdiff
path: root/reconfigure/tests/parsers/base_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'reconfigure/tests/parsers/base_test.py')
-rw-r--r--reconfigure/tests/parsers/base_test.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/reconfigure/tests/parsers/base_test.py b/reconfigure/tests/parsers/base_test.py
new file mode 100644
index 0000000..74c94b5
--- /dev/null
+++ b/reconfigure/tests/parsers/base_test.py
@@ -0,0 +1,30 @@
+import unittest
+
+
+class BaseParserTest (unittest.TestCase):
+ source = ""
+ parsed = None
+ parser = None
+
+ @property
+ def stringified(self):
+ return self.source
+
+ def test_parse(self):
+ if not self.__class__.parser:
+ return
+
+ nodetree = self.parser.parse(self.__class__.source)
+ if self.__class__.parsed != nodetree:
+ print 'TARGET: %s\n\nPARSED: %s' % (self.__class__.parsed, nodetree)
+ self.assertEquals(self.__class__.parsed, nodetree)
+
+ def test_stringify(self):
+ if not self.__class__.parser:
+ return
+
+ unparsed = self.parser.stringify(self.__class__.parsed)
+ a, b = self.stringified, unparsed
+ if a.split() != b.split():
+ print 'SOURCE: %s\n\nGENERATED: %s' % (a, b)
+ self.assertEquals(a.split(), b.split())