~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_trace.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-22 12:52:39 UTC
  • mto: (4471.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4472.
  • Revision ID: v.ladeuil+lp@free.fr-20090622125239-kabo9smxt9c3vnir
Use a consistent scheme for naming pyrex source files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
# "weren't nothing promised to you.  do i look like i got a promise face?"
18
18
 
70
70
 
71
71
    def test_format_os_error(self):
72
72
        try:
 
73
            os.rmdir('nosuchfile22222')
 
74
        except OSError:
 
75
            pass
 
76
        msg = _format_exception()
 
77
        self.assertContainsRe(msg,
 
78
            r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile22222')
 
79
 
 
80
    def test_format_io_error(self):
 
81
        try:
73
82
            file('nosuchfile22222')
74
 
        except (OSError, IOError):
 
83
        except IOError:
75
84
            pass
76
85
        msg = _format_exception()
77
86
        self.assertContainsRe(msg, r'^bzr: ERROR: \[Errno .*\] No such file.*nosuchfile')
93
102
        self.assertTrue(len(msg) > 0)
94
103
        self.assertEqualDiff(msg, 'bzr: ERROR: Not a branch: \"wibble\".\n')
95
104
 
 
105
    def test_report_external_import_error(self):
 
106
        """Short friendly message for missing system modules."""
 
107
        try:
 
108
            import ImaginaryModule
 
109
        except ImportError, e:
 
110
            pass
 
111
        else:
 
112
            self.fail("somehow succeeded in importing %r" % ImaginaryModule)
 
113
        msg = _format_exception()
 
114
        self.assertEqual(msg,
 
115
            'bzr: ERROR: No module named ImaginaryModule\n'
 
116
            'You may need to install this Python library separately.\n')
 
117
 
 
118
    def test_report_import_syntax_error(self):
 
119
        try:
 
120
            raise ImportError("syntax error")
 
121
        except ImportError, e:
 
122
            pass
 
123
        msg = _format_exception()
 
124
        self.assertContainsRe(msg,
 
125
            r"Traceback \(most recent call last\)")
 
126
 
96
127
    def test_trace_unicode(self):
97
128
        """Write Unicode to trace log"""
98
129
        self.log(u'the unicode character for benzene is \N{BENZENE RING}')
99
130
        self.assertContainsRe(self._get_log(keep_log_file=True),
100
131
                              "the unicode character for benzene is")
101
 
    
 
132
 
102
133
    def test_trace_argument_unicode(self):
103
134
        """Write a Unicode argument to the trace log"""
104
135
        mutter(u'the unicode character for benzene is %s', u'\N{BENZENE RING}')
164
195
    def test_push_log_file(self):
165
196
        """Can push and pop log file, and this catches mutter messages.
166
197
 
167
 
        This is primarily for use in the test framework. 
 
198
        This is primarily for use in the test framework.
168
199
        """
169
200
        tmp1 = tempfile.NamedTemporaryFile()
170
201
        tmp2 = tempfile.NamedTemporaryFile()