1922
1923
r"bzr: warning: some compiled extensions could not be loaded; "
1923
1924
"see <https://answers\.launchpad\.net/bzr/\+faq/703>\n"
1928
class TestTerminalWidth(tests.TestCase):
1930
def test_default_values(self):
1931
self.assertEquals(80, osutils.default_terminal_width)
1933
def test_defaults_to_BZR_COLUMNS(self):
1934
# BZR_COLUMNS is set by the test framework
1935
self.assertEquals('80', os.environ['BZR_COLUMNS'])
1936
os.environ['BZR_COLUMNS'] = '12'
1937
self.assertEquals(12, osutils.terminal_width())
1939
def test_tty_default_without_columns(self):
1940
del os.environ['BZR_COLUMNS']
1941
del os.environ['COLUMNS']
1942
orig_stdout = sys.stdout
1944
sys.stdout = orig_stdout
1945
self.addCleanup(restore)
1947
class I_am_a_tty(object):
1951
sys.stdout = I_am_a_tty()
1952
self.assertEquals(None, osutils.terminal_width())
1954
def test_non_tty_default_without_columns(self):
1955
del os.environ['BZR_COLUMNS']
1956
del os.environ['COLUMNS']
1957
orig_stdout = sys.stdout
1959
sys.stdout = orig_stdout
1960
self.addCleanup(restore)
1962
self.assertEquals(None, osutils.terminal_width())
1964
def test_TIOCGWINSZ(self):
1965
# bug 63539 is about a termios without TIOCGWINSZ attribute
1968
orig = termios.TIOCGWINSZ
1969
except AttributeError:
1974
termios.TIOCGWINSZ = orig
1975
self.addCleanup(restore)
1977
del termios.TIOCGWINSZ
1978
del os.environ['BZR_COLUMNS']
1979
del os.environ['COLUMNS']
1980
self.assertEquals(None, osutils.terminal_width())