/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_crash.py

  • Committer: Jelmer Vernooij
  • Date: 2017-07-23 22:06:41 UTC
  • mfrom: (6738 trunk)
  • mto: This revision was merged to the branch mainline in revision 6739.
  • Revision ID: jelmer@jelmer.uk-20170723220641-69eczax9bmv8d6kk
Merge trunk, address review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import doctest
19
 
from io import StringIO
20
19
import os
21
20
import sys
22
21
 
23
22
import breezy
24
23
from .. import (
25
 
    bedding,
 
24
    config,
26
25
    crash,
27
26
    osutils,
28
27
    plugin,
29
28
    tests,
30
29
    )
 
30
from ..sixish import (
 
31
    StringIO,
 
32
    )
31
33
from . import features
32
34
 
33
35
 
39
41
        crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
40
42
        os.mkdir(crash_dir)
41
43
        self.overrideEnv('APPORT_CRASH_DIR', crash_dir)
42
 
        self.assertEqual(crash_dir, bedding.crash_dir())
 
44
        self.assertEqual(crash_dir, config.crash_dir())
43
45
 
44
46
        self.overrideAttr(
45
 
            breezy.get_global_state(),
 
47
            breezy.global_state,
46
48
            'plugin_warnings',
47
49
            {'example': ['Failed to load plugin foo']})
48
50
 
55
57
 
56
58
        # message explaining the crash
57
59
        self.assertContainsRe(stderr.getvalue(),
58
 
                              "    apport-bug %s" % crash_filename)
 
60
            "    apport-bug %s" % crash_filename)
59
61
 
60
62
        with open(crash_filename) as crash_file:
61
63
            report = crash_file.read()
62
64
 
63
65
        self.assertContainsRe(report,
64
 
                              '(?m)^BrzVersion:')  # should be in the traceback
 
66
            '(?m)^BrzVersion:') # should be in the traceback
65
67
        self.assertContainsRe(report, 'my error')
66
68
        self.assertContainsRe(report, 'AssertionError')
67
69
        # see https://bugs.launchpad.net/bzr/+bug/528114
84
86
        fake = plugin.PlugIn('fake_plugin', plugin)
85
87
        fake.version_info = lambda: (1, 2, 3)
86
88
        fake_plugins = {"fake_plugin": fake}
87
 
        self.overrideAttr(breezy.get_global_state(), 'plugins', fake_plugins)
 
89
        self.overrideAttr(breezy.global_state, 'plugins', fake_plugins)
88
90
 
89
91
    def test_report_bug_legacy(self):
90
92
        self.setup_fake_plugins()
95
97
            crash.report_bug_legacy(sys.exc_info(), err_file)
96
98
        report = err_file.getvalue()
97
99
        for needle in [
98
 
                "brz: ERROR: AssertionError: my error",
99
 
                r"Traceback \(most recent call last\):",
100
 
                r"plugins: fake_plugin\[1\.2\.3\]",
101
 
                ]:
 
100
            "brz: ERROR: AssertionError: my error",
 
101
            r"Traceback \(most recent call last\):",
 
102
            r"plugins: fake_plugin\[1\.2\.3\]",
 
103
            ]:
102
104
            self.assertContainsRe(report, needle)