summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Verfaillie <dieterv@optionexplicit.be>2015-03-04 21:19:52 +0100
committerDieter Verfaillie <dieterv@optionexplicit.be>2015-06-24 21:31:14 +0200
commiteddc7020c003ea9a2ed9d6c3a9f0e03654f4b268 (patch)
tree524abb496e6897f6eda98c4df76916eabc29b976
parentd4bd173bbcf400c93c895ba9899abbf1d3165102 (diff)
downloadgobject-introspection-eddc7020c003ea9a2ed9d6c3a9f0e03654f4b268.tar.gz
tests: execute annotationparser tests just once
42bb69a6a2f12165a9758b192e80da089e00ab5c introduced a bug causing test_parser.py and test_patterns.py tests to be executed twice. This patch fixes this and still allows the tests to be executed: - using 'make check' - manually: PYTHONPATH=. python tests/scanner/annotationparser/test_parser.py PYTHONPATH=. python tests/scanner/annotationparser/test_patterns.py - individually: python -m unittest test_parser.TestGiTag_Stability.test_001 python -m unittest test_patterns.TestCommentAsterisk.test_000 test_parser.py now results in: Ran 360 tests in 0.172s instead of: Ran 720 tests in 0.339s test_patterns.py now results in: Ran 213 tests in 0.014s instead of Ran 426 tests in 0.041s https://bugzilla.gnome.org/show_bug.cgi?id=745636
-rw-r--r--tests/scanner/annotationparser/test_parser.py21
-rw-r--r--tests/scanner/annotationparser/test_patterns.py26
2 files changed, 7 insertions, 40 deletions
diff --git a/tests/scanner/annotationparser/test_parser.py b/tests/scanner/annotationparser/test_parser.py
index 19219386..99c5da79 100644
--- a/tests/scanner/annotationparser/test_parser.py
+++ b/tests/scanner/annotationparser/test_parser.py
@@ -436,26 +436,5 @@ _all_tests = create_test_cases()
globals().update(_all_tests)
-# Hook function for Python test loader.
-def load_tests(loader, tests, pattern):
- suite = unittest.TestSuite()
- # add standard tests from module
- suite.addTests(tests)
-
- # Initialize message logger
- namespace = Namespace('Test', '1.0')
- logger = MessageLogger.get(namespace=namespace)
- logger.enable_warnings((WARNING, ERROR, FATAL))
-
- # Load test cases from disc
- tests_dir = os.path.dirname(os.path.abspath(__file__))
-
- for name, test_case in _all_tests.items():
- tests = loader.loadTestsFromTestCase(test_case)
- suite.addTests(tests)
- return suite
-
-
if __name__ == '__main__':
- # Run test suite
unittest.main()
diff --git a/tests/scanner/annotationparser/test_patterns.py b/tests/scanner/annotationparser/test_patterns.py
index b53f537f..738a83ff 100644
--- a/tests/scanner/annotationparser/test_patterns.py
+++ b/tests/scanner/annotationparser/test_patterns.py
@@ -889,12 +889,11 @@ def create_test_method(testcase):
def create_test_case(tests_class_name, testcases):
test_methods = {}
- for (index, testcase) in enumerate(testcases):
- test_method_name = 'test_%03d' % index
-
- test_method = create_test_method(testcase)
- test_method.__name__ = test_method_name
- test_methods[test_method_name] = test_method
+ for counter, test in enumerate(testcases):
+ test_name = 'test_%03d' % (counter + 1)
+ test_method = create_test_method(test)
+ test_method.__name__ = test_name
+ test_methods[test_name] = test_method
return type(tests_class_name, (unittest.TestCase,), test_methods)
@@ -914,7 +913,8 @@ def create_test_cases():
('TestTag', tag_tests),
('TestTagValueVersion', tag_value_version_tests),
('TestTagValueStability', tag_value_stability_tests)):
- test_cases[name] = create_test_case(name, test_data)
+ test_case = create_test_case(name, test_data)
+ test_cases[test_case.__name__] = test_case
return test_cases
@@ -927,17 +927,5 @@ _all_tests = create_test_cases()
globals().update(_all_tests)
-# Hook function for Python test loader.
-def load_tests(loader, tests, pattern):
- suite = unittest.TestSuite()
- # add standard tests from module
- suite.addTests(tests)
-
- for name, test_case in _all_tests.items():
- tests = loader.loadTestsFromTestCase(test_case)
- suite.addTests(tests)
- return suite
-
-
if __name__ == '__main__':
unittest.main()