[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Simplifying _get_tests()
commit 6a9c9a63b81c12679751f4c73e76fcc964680742
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Mar 3 08:47:27 2015 -0800
Simplifying _get_tests()
Our module_prefixes fall into two camps...
* It's... well, a module prefix. It'll be a prefix of our import name.
* It's an exact match for a test. Our import name will be a prefix of it.
No need to strip off the last component and try again. We can do this in one
pass. One thing I noticed though is that we don't check to see if tests exist.
We rely on a try/catch for that. Might be able to wrap it into this helper -
we'll see.
---
test/util.py | 33 +++++++++------------------------
1 file changed, 9 insertions(+), 24 deletions(-)
diff --git a/test/util.py b/test/util.py
index 78be64b..35909e5 100644
--- a/test/util.py
+++ b/test/util.py
@@ -108,33 +108,18 @@ def get_integ_tests(module_prefix = None):
def _get_tests(modules, module_prefix):
- # Look for module_prefix in the list of all modules
- modules_found = 0
for import_name in modules:
if import_name:
- if module_prefix and not import_name.startswith(module_prefix):
- continue
+ if not module_prefix or import_name.startswith(module_prefix):
+ yield import_name
+ elif module_prefix.startswith(import_name):
+ # might be a single test in this module, check if we match any
+
+ module, test = module_prefix.rsplit('.', 1)
+
+ # TODO: should check if the test exists
- modules_found += 1
- yield import_name
-
- # If no modules were found, then it might be that we were given
- # a method (e.g test.integ.process.some_method).
- # Delete the method substring and look again in the list of modules
- if modules_found == 0:
- module_list = module_prefix.split('.')
- # At this point all module_prefix should be test.{integ|unit}.something
- if(len(module_list) > 3):
- module_prefix = '.'.join(module_list[:-1])
- class_method = module_list[-1]
-
- for import_name in modules:
- if import_name:
- if module_prefix and not import_name.startswith(module_prefix):
- continue
-
- # If found, return module.method
- yield import_name + '.' + class_method
+ yield module_prefix
def get_help_message():
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits