diff options
author | Michal Minar <miminar@redhat.com> | 2012-12-12 10:51:40 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2012-12-13 13:27:31 +0100 |
commit | 54e501a7225d30695bdcc2edb3b406986290e6e6 (patch) | |
tree | 905c4c0ac5a4c746e75c9006ca63013cd53c6864 /src/software/test/run.py | |
parent | 51d608eb5db9d977750709fb9ad4a0fad2be6c02 (diff) | |
download | openlmi-providers-54e501a7225d30695bdcc2edb3b406986290e6e6.tar.gz openlmi-providers-54e501a7225d30695bdcc2edb3b406986290e6e6.tar.xz openlmi-providers-54e501a7225d30695bdcc2edb3b406986290e6e6.zip |
fixed test selection, when launching tests with run
particular tests can be selected like this:
* # runs all tests defined by this test case
./run.py -- TestSoftwarePackage
* # runs single test defined by TestSoftwarePackage TestCase
./run.py -- TestSoftwarePackage.test_get_instance
added comments for each assert
made results of tests a lot more readable
different file mode for symlinks passes like in rpm -V
increased number of packages for testing to 5
Diffstat (limited to 'src/software/test/run.py')
-rwxr-xr-x | src/software/test/run.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/software/test/run.py b/src/software/test/run.py index 002bf77..aba362f 100755 --- a/src/software/test/run.py +++ b/src/software/test/run.py @@ -44,6 +44,11 @@ import rpmcache # argument CACHE_DIR = '' +class NotFound(Exception): + """Raised when test of particular name could no be found.""" + def __init__(self, name): + Exception.__init__(self, "Test \"%s\" could not be found!" % name) + def parse_cmd_line(): """ Use ArgumentParser to parse command line arguments. @@ -179,13 +184,18 @@ class LMITestLoader(unittest.TestLoader): @param name is a name of test to find @return desired TestCase or test function """ + if ( isinstance(node, unittest.TestSuite) + and isinstance(next(iter(node)), unittest.TestCase) + and next(iter(node)).__class__.__name__ == name): + return node for subnode in node: if isinstance(subnode, unittest.TestSuite): subnode = LMITestLoader.find_in_test_nodes(subnode, name) if subnode is not None: return subnode elif isinstance(subnode, unittest.TestCase): - if name == subnode.__class__.__name__: + if ( name == subnode.__class__.__name__ + or name == subnode._testMethodName): return subnode elif inspect.isfunction(subnode) and name == subnode.__name__: return subnode @@ -201,8 +211,7 @@ class LMITestLoader(unittest.TestLoader): for part in parts: node = LMITestLoader.find_in_test_nodes(node, part) if node is None: - # name not found - return unittest.TestLoader.loadTestsFromName(self, name, module) + raise NotFound(name) return node def unwind_test_suite_tree(node): |