/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 breezy/tests/test_trace.py

  • Committer: Jelmer Vernooij
  • Date: 2019-06-03 23:48:08 UTC
  • mfrom: (7316 work)
  • mto: This revision was merged to the branch mainline in revision 7328.
  • Revision ID: jelmer@jelmer.uk-20190603234808-15yk5c7054tj8e2b
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    PY3,
35
35
    StringIO,
36
36
    )
37
 
from . import features, TestCaseInTempDir, TestCase, TestSkipped
 
37
from . import features, TestCaseInTempDir, TestCase
38
38
from ..trace import (
39
39
    mutter, mutter_callsite, report_exception,
40
40
    set_verbosity_level, get_verbosity_level, is_quiet, is_verbose, be_quiet,
327
327
        self.overrideEnv('BRZ_LOG', '/no-such-dir/brz.log')
328
328
        self.overrideAttr(trace, '_brz_log_filename')
329
329
        logf = trace._open_brz_log()
330
 
        if os.path.isdir('/no-such-dir'):
331
 
            raise TestSkipped('directory creation succeeded')
332
330
        self.assertIs(None, logf)
333
331
        self.assertContainsRe(
334
332
            sys.stderr.getvalue(),
335
333
            "failed to open trace file: .* '/no-such-dir/brz.log'$")
336
334
 
337
 
    def test__open_brz_log_ignores_cache_dir_error(self):
338
 
        # If the cache directory can not be created and _open_brz_log can thus
339
 
        # not open the file, then we should write the warning to stderr. Since
340
 
        # this is normally happening before logging is set up.
341
 
        self.overrideAttr(sys, 'stderr', StringIO())
342
 
        # Set the cache directory to something that cannot exist
343
 
        self.overrideEnv('BRZ_LOG', None)
344
 
        self.overrideEnv('BRZ_HOME', '/no-such-dir')
345
 
        self.overrideEnv('XDG_CACHE_HOME', '/no-such-dir')
346
 
        self.overrideAttr(trace, '_brz_log_filename')
347
 
        logf = trace._open_brz_log()
348
 
        if os.path.isdir('/no-such-dir'):
349
 
            raise TestSkipped('directory creation succeeded')
350
 
        self.assertIs(None, logf)
351
 
        self.assertContainsRe(
352
 
            sys.stderr.getvalue(),
353
 
            "failed to open trace file: .* '/no-such-dir'$")
354
 
 
355
335
 
356
336
class TestVerbosityLevel(TestCase):
357
337