~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

terminal_width can now returns None.

* bzrlib/win32utils.py:
(get_console_size): Fix typo in comment.

* bzrlib/ui/text.py:
(TextProgressView._show_line): Handle the no terminal present case.

* bzrlib/tests/test_osutils.py:
(TestTerminalWidth): Update tests.

* bzrlib/tests/blackbox/test_too_much.py:
Fix some imports.
(OldTests.test_bzr): Handle the no terminal present case.

* bzrlib/tests/__init__.py:
(VerboseTestResult.report_test_start): Handle the no terminal
present case.

* bzrlib/status.py:
(show_pending_merges): Handle the no terminal present case.
(show_pending_merges.show_log_message): Factor out some
code. Handle the no terminal present case.

* bzrlib/osutils.py:
(terminal_width): Return None if no precise value can be found.

* bzrlib/log.py:
(LineLogFormatter.__init__): Handle the no terminal present case.
(LineLogFormatter.truncate): Accept None as max_len meaning no
truncation.
(LineLogFormatter.log_string): 

* bzrlib/help.py:
(_help_commands_to_text): Handle the no terminal present case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 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
23
23
 
24
24
from bzrlib import (
25
25
    errors,
26
 
    registry,
 
26
    symbol_versioning,
27
27
    tests,
28
28
    version_info_formats,
29
29
    )
136
136
            return new_stanzas[0]
137
137
 
138
138
        stanza = regen()
139
 
        self.assertTrue('date' in stanza)
140
 
        self.assertTrue('build-date' in stanza)
 
139
        self.failUnless('date' in stanza)
 
140
        self.failUnless('build-date' in stanza)
141
141
        self.assertEqual(['3'], stanza.get_all('revno'))
142
142
        self.assertEqual(['r3'], stanza.get_all('revision-id'))
143
143
 
192
192
        val = sio.getvalue()
193
193
        self.assertContainsRe(val, "'revision_id': None")
194
194
        self.assertContainsRe(val, "'revno': 0")
195
 
        self.assertNotContainsString(val, '\n\n\n\n')
196
195
 
197
196
    def test_python_version(self):
198
197
        wt = self.create_branch()
225
224
        tvi = regen()
226
225
        self.assertEqual(3, tvi.version_info['revno'])
227
226
        self.assertEqual('r3', tvi.version_info['revision_id'])
228
 
        self.assertTrue(tvi.version_info.has_key('date'))
 
227
        self.failUnless(tvi.version_info.has_key('date'))
229
228
        self.assertEqual(None, tvi.version_info['clean'])
230
229
 
231
230
        tvi = regen(check_for_clean=True)
326
325
 
327
326
    def setUp(self):
328
327
        super(TestVersionInfoFormatRegistry, self).setUp()
329
 
        self.overrideAttr(version_info_formats,
330
 
                          'format_registry', registry.Registry())
 
328
        registry = version_info_formats.format_registry
 
329
        self._default_key = registry._default_key
 
330
        self._dict = registry._dict.copy()
 
331
        self._help_dict = registry._help_dict.copy()
 
332
        self._info_dict = registry._info_dict.copy()
 
333
        self.addCleanup(self._cleanup)
 
334
 
 
335
    def _cleanup(self):
 
336
        # Restore the registry to pristine state after the test runs
 
337
        registry = version_info_formats.format_registry
 
338
        registry._default_key = self._default_key
 
339
        registry._dict = self._dict
 
340
        registry._help_dict = self._help_dict
 
341
        registry._info_dict = self._info_dict
331
342
 
332
343
    def test_register_remove(self):
333
344
        registry = version_info_formats.format_registry