[gobject-introspection] tests: compare matched groups when testing re's



commit 8ba87a7a8d91ec4eb26a0fa294280d09b52543f4
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date:   Thu Jul 18 07:22:03 2013 +0200

    tests: compare matched groups when testing re's

 tests/scanner/annotationparser/test_patterns.py |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index 6db99c3..97e6687 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -589,6 +589,14 @@ class TestProgram(TestCase):
 
             match = program.match(text)
 
+            if match is not None:
+                msg = 'Test matched pattern but specifies no expected named groups.'
+                self.assertTrue(isinstance(expected, dict), msg)
+
+                for group in match.groupdict().keys():
+                    msg = 'Test case is missing expected results for named group "%s".' % (group)
+                    self.assertTrue(group in expected.keys(), msg)
+
             if expected is None:
                 msg = 'Program matched text but shouldn\'t:\n"%s"'
                 self.assertTrue(match is None, msg % (text, ))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]