/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: Alexander Belchenko
  • Date: 2007-01-30 10:51:38 UTC
  • mto: This revision was merged to the branch mainline in revision 2259.
  • Revision ID: bialix@ukr.net-20070130105138-280dj0ayzeh886rb
trace.py: open_tracefile(): win98-compatible detection of location for .bzr.log

It's also change default location of .bzr.log on Windows 2000/XP as well:
now it in user's My Documents folder, so it's much better 
for users without administarator priveleges.

Also workaround win32-specific issue with file.tell().

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):