~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_crash.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-07 18:23:13 UTC
  • mto: (6615.3.1 2.7)
  • mto: This revision was merged to the branch mainline in revision 6620.
  • Revision ID: v.ladeuil+lp@free.fr-20160207182313-jwz7z3vj4mpyjn7y
Ensure http://pad.lv/1323805 won't come back.

Since the 2.6.0 release pypi policy changed and release tarballs can't be
hosted on launchpad anymore, they have to be uploaded to
http://pypi.python.org/pypi


This fixes setup.py sdist to generate the right tarball with nearly the same
content as the one produced for 2.7.0.

Such a tarball have been uploaded to pypi properly signed and tested for
installation in venv.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 2011, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
 
18
import doctest
 
19
import os
18
20
from StringIO import StringIO
19
21
import sys
20
22
 
21
 
 
22
 
import os
23
 
 
24
 
 
25
23
from bzrlib import (
26
24
    config,
27
25
    crash,
28
26
    osutils,
29
 
    symbol_versioning,
 
27
    plugin,
30
28
    tests,
31
29
    )
32
30
 
40
38
    def test_apport_report(self):
41
39
        crash_dir = osutils.joinpath((self.test_base_dir, 'crash'))
42
40
        os.mkdir(crash_dir)
43
 
        os.environ['APPORT_CRASH_DIR'] = crash_dir
44
 
        self.assertEquals(crash_dir, config.crash_dir())
 
41
        self.overrideEnv('APPORT_CRASH_DIR', crash_dir)
 
42
        self.assertEqual(crash_dir, config.crash_dir())
 
43
 
 
44
        self.overrideAttr(
 
45
            plugin,
 
46
            'plugin_warnings',
 
47
            {'example': ['Failed to load plugin foo']})
45
48
 
46
49
        stderr = StringIO()
47
50
 
72
75
        self.assertContainsRe(report, 'test_apport_report')
73
76
        # should also be in there
74
77
        self.assertContainsRe(report, '(?m)^CommandLine:')
 
78
        self.assertContainsRe(
 
79
            report,
 
80
            'Failed to load plugin foo')
 
81
 
 
82
 
 
83
class TestNonApportReporting(tests.TestCase):
 
84
    """Reporting of crash-type bugs without apport.
 
85
    
 
86
    This should work in all environments.
 
87
    """
 
88
 
 
89
    def setup_fake_plugins(self):
 
90
        def fake_plugins():
 
91
            fake = plugin.PlugIn('fake_plugin', plugin)
 
92
            fake.version_info = lambda: (1, 2, 3)
 
93
            return {"fake_plugin": fake}
 
94
        self.overrideAttr(plugin, 'plugins', fake_plugins)
 
95
 
 
96
    def test_report_bug_legacy(self):
 
97
        self.setup_fake_plugins()
 
98
        err_file = StringIO()
 
99
        try:
 
100
            raise AssertionError("my error")
 
101
        except AssertionError, e:
 
102
            pass
 
103
        crash.report_bug_legacy(sys.exc_info(), err_file)
 
104
        report = err_file.getvalue()
 
105
        for needle in [
 
106
            "bzr: ERROR: exceptions.AssertionError: my error",
 
107
            r"Traceback \(most recent call last\):",
 
108
            r"plugins: fake_plugin\[1\.2\.3\]",
 
109
            ]:
 
110
            self.assertContainsRe(
 
111
                    report,
 
112
                    needle)