[tor-commits] [stem/master] Moving test filter to helper function
atagar at torproject.org
atagar at torproject.org
Sun Apr 14 04:33:46 UTC 2013
commit 347d2859073672e9c0354727901769245fb3b758
Author: Damian Johnson <atagar at torproject.org>
Date: Thu Apr 11 08:35:31 2013 -0700
Moving test filter to helper function
Shifting support for the '--test' argument to the helper. Oh, and the integ
helper was running the unit tests instead. ;)
---
run_tests.py | 12 ++----------
test/runner.py | 30 ++++++++++++++++++++++--------
2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/run_tests.py b/run_tests.py
index 096de69..3de1fbf 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -358,11 +358,7 @@ if __name__ == '__main__':
test.output.print_divider("UNIT TESTS", True)
error_tracker.set_category("UNIT TEST")
- for test_class in test.runner.get_unit_tests():
- if CONFIG["argument.test"] and \
- not test_class.__module__.startswith(CONFIG["argument.test"]):
- continue
-
+ for test_class in test.runner.get_unit_tests(CONFIG["argument.test"]):
test.output.print_divider(test_class.__module__)
suite = unittest.TestLoader().loadTestsFromTestCase(test_class)
test_results = StringIO.StringIO()
@@ -442,11 +438,7 @@ if __name__ == '__main__':
test.output.print_line("Running tests...", term.Color.BLUE, term.Attr.BOLD)
print
- for test_class in test.runner.get_integ_tests():
- if CONFIG["argument.test"] and \
- not test_class.__module__.startswith(CONFIG["argument.test"]):
- continue
-
+ for test_class in test.runner.get_integ_tests(CONFIG["argument.test"]):
test.output.print_divider(test_class.__module__)
suite = unittest.TestLoader().loadTestsFromTestCase(test_class)
test_results = StringIO.StringIO()
diff --git a/test/runner.py b/test/runner.py
index 592d367..9e809fe 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -217,28 +217,42 @@ def exercise_controller(test_case, controller):
-def get_unit_tests():
+def get_unit_tests(prefix = None):
"""
Provides the classes for our unit tests.
+ :param str prefix: only provide the test if the module starts with this prefix
+
:returns: an **iterator** for our unit tests
"""
- for test_module in CONFIG["test.unit_tests"].splitlines():
- if test_module:
- yield _import_test(test_module)
+ for line in CONFIG["test.unit_tests"].splitlines():
+ if line:
+ test_class = _import_test(line)
+
+ if prefix and not test_class.__module__.startswith(prefix):
+ continue
+
+ yield test_class
-def get_integ_tests():
+def get_integ_tests(prefix = None):
"""
Provides the classes for our integration tests.
+ :param str prefix: only provide the test if the module starts with this prefix
+
:returns: an **iterator** for our integration tests
"""
- for test_module in CONFIG["test.unit_tests"].splitlines():
- if test_module:
- yield _import_test(test_module)
+ for line in CONFIG["test.integ_tests"].splitlines():
+ if line:
+ test_class = _import_test(line)
+
+ if prefix and not test_class.__module__.startswith(prefix):
+ continue
+
+ yield test_class
def _import_test(import_name):
More information about the tor-commits
mailing list