/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

  • Committer: Robert Collins
  • Date: 2007-04-18 08:39:02 UTC
  • mto: (2425.1.2 integration)
  • mto: This revision was merged to the branch mainline in revision 2427.
  • Revision ID: robertc@robertcollins.net-20070418083902-4o66h9fk7zeisvwa
Command objects can now declare related help topics by having _see_also
set to a list of related topic. Updated the HACKING guide entry on
documentation to be more clear about how the help for commands is
generated and to reference this new feature. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2004 Canonical Limited
 
1
# Copyright (C) 2004, 2005, 2006 Canonical Ltd
2
2
#       Author: Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
69
69
 
70
70
 
71
71
class TestLoader(unittest.TestLoader):
72
 
    """Custome TestLoader to set the right TestSuite class."""
 
72
    """Custom  TestLoader to address some quirks in the stock python one."""
73
73
    suiteClass = TestSuite
74
74
 
 
75
    def loadTestsFromModuleNames(self, names):
 
76
        """use a custom means to load tests from modules.
 
77
 
 
78
        There is an undesirable glitch in the python TestLoader where a 
 
79
        import error is ignore. We think this can be solved by ensuring the 
 
80
        requested name is resolvable, if its not raising the original error.
 
81
        """
 
82
        result = self.suiteClass()
 
83
        for name in names:
 
84
            _load_module_by_name(name)
 
85
            result.addTests(self.loadTestsFromName(name))
 
86
        return result
 
87
 
 
88
 
 
89
def _load_module_by_name(mod_name):
 
90
    parts = mod_name.split('.')
 
91
    module = __import__(mod_name)
 
92
    del parts[0]
 
93
    # for historical reasons python returns the top-level module even though
 
94
    # it loads the submodule; we need to walk down to get the one we want.
 
95
    while parts:
 
96
        module = getattr(module, parts.pop(0))
 
97
    return module
 
98
 
 
99
 
75
100
class TestVisitor(object):
76
101
    """A visitor for Tests"""
77
102
    def visitSuite(self, aTestSuite):