~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.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:
1886
1886
class TestTerminalWidth(tests.TestCase):
1887
1887
 
1888
1888
    def test_default_values(self):
1889
 
        self.assertEquals(80, osutils.default_tty_width)
1890
 
        self.assertEquals(256, osutils.default_non_tty_width)
 
1889
        self.assertEquals(80, osutils.default_terminal_width)
1891
1890
 
1892
1891
    def test_defaults_to_COLUMNS(self):
1893
1892
        # COLUMNS is set by the test framework
1907
1906
                return True
1908
1907
 
1909
1908
        sys.stdout = I_am_a_tty()
1910
 
        self.assertEquals(osutils.default_tty_width, osutils.terminal_width())
 
1909
        self.assertEquals(None, osutils.terminal_width())
1911
1910
 
1912
1911
    def test_non_tty_default_without_columns(self):
1913
1912
        del os.environ['COLUMNS']
1916
1915
            sys.stdout = orig_stdout
1917
1916
        self.addCleanup(restore)
1918
1917
        sys.stdout = None
1919
 
        self.assertEquals(osutils.default_non_tty_width,
1920
 
                          osutils.terminal_width())
 
1918
        self.assertEquals(None, osutils.terminal_width())
1921
1919
 
1922
1920
    def test_TIOCGWINSZ(self):
1923
1921
        # bug 63539 is about a termios without TIOCGWINSZ attribute
1931
1929
            if exist:
1932
1930
                termios.TIOCGWINSZ = orig
1933
1931
        self.addCleanup(restore)
 
1932
 
1934
1933
        del termios.TIOCGWINSZ
1935
 
        self.assertEquals(osutils.default_tty_width, osutils.terminal_width())
 
1934
        del os.environ['COLUMNS']
 
1935
        self.assertEquals(None, osutils.terminal_width())