~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Jonathan Riddell
  • Date: 2011-06-21 11:34:52 UTC
  • mfrom: (5989 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6003.
  • Revision ID: jriddell@canonical.com-20110621113452-ktj67zy52th919c8
mergeĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
    'BZREMAIL': None, # may still be present in the environment
143
143
    'EMAIL': 'jrandom@example.com', # set EMAIL as bzr does not guess
144
144
    'BZR_PROGRESS_BAR': None,
145
 
    'BZR_LOG': None,
 
145
    # This should trap leaks to ~/.bzr.log. This occurs when tests use TestCase
 
146
    # as a base class instead of TestCaseInTempDir. Tests inheriting from
 
147
    # TestCase should not use disk resources, BZR_LOG is one.
 
148
    'BZR_LOG': '/you-should-use-TestCaseInTempDir-if-you-need-a-log-file',
146
149
    'BZR_PLUGIN_PATH': None,
147
150
    'BZR_DISABLE_PLUGINS': None,
148
151
    'BZR_PLUGINS_AT': None,
928
931
 
929
932
    The method is really a factory and users are expected to use it as such.
930
933
    """
931
 
    
 
934
 
932
935
    kwargs['setUp'] = isolated_doctest_setUp
933
936
    kwargs['tearDown'] = isolated_doctest_tearDown
934
937
    return doctest.DocTestSuite(*args, **kwargs)
1704
1707
    def _finishLogFile(self):
1705
1708
        """Finished with the log file.
1706
1709
 
1707
 
        Close the file and delete it, unless setKeepLogfile was called.
 
1710
        Close the file and delete it.
1708
1711
        """
1709
1712
        if trace._trace_file:
1710
1713
            # flush the log file, to get all content
2325
2328
class TestCaseWithMemoryTransport(TestCase):
2326
2329
    """Common test class for tests that do not need disk resources.
2327
2330
 
2328
 
    Tests that need disk resources should derive from TestCaseWithTransport.
 
2331
    Tests that need disk resources should derive from TestCaseInTempDir
 
2332
    orTestCaseWithTransport.
2329
2333
 
2330
2334
    TestCaseWithMemoryTransport sets the TEST_ROOT variable for all bzr tests.
2331
2335
 
2332
 
    For TestCaseWithMemoryTransport the test_home_dir is set to the name of
 
2336
    For TestCaseWithMemoryTransport the ``test_home_dir`` is set to the name of
2333
2337
    a directory which does not exist. This serves to help ensure test isolation
2334
 
    is preserved. test_dir is set to the TEST_ROOT, as is cwd, because they
2335
 
    must exist. However, TestCaseWithMemoryTransport does not offer local
2336
 
    file defaults for the transport in tests, nor does it obey the command line
 
2338
    is preserved. ``test_dir`` is set to the TEST_ROOT, as is cwd, because they
 
2339
    must exist. However, TestCaseWithMemoryTransport does not offer local file
 
2340
    defaults for the transport in tests, nor does it obey the command line
2337
2341
    override, so tests that accidentally write to the common directory should
2338
2342
    be rare.
2339
2343
 
2340
 
    :cvar TEST_ROOT: Directory containing all temporary directories, plus
2341
 
    a .bzr directory that stops us ascending higher into the filesystem.
 
2344
    :cvar TEST_ROOT: Directory containing all temporary directories, plus a
 
2345
        ``.bzr`` directory that stops us ascending higher into the filesystem.
2342
2346
    """
2343
2347
 
2344
2348
    TEST_ROOT = None
2668
2672
 
2669
2673
    OVERRIDE_PYTHON = 'python'
2670
2674
 
 
2675
    def setUp(self):
 
2676
        super(TestCaseInTempDir, self).setUp()
 
2677
        # Remove the protection set in isolated_environ, we have a proper
 
2678
        # access to disk resources now.
 
2679
        self.overrideEnv('BZR_LOG', None)
 
2680
 
2671
2681
    def check_file_contents(self, filename, expect):
2672
2682
        self.log("check contents of file %s" % filename)
2673
2683
        f = file(filename)