Rev 4762: Fix broken test (fail on windows). in file:///home/vila/src/bzr/bugs/353370-notty-no-term-width/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Dec 9 15:09:00 GMT 2009


At file:///home/vila/src/bzr/bugs/353370-notty-no-term-width/

------------------------------------------------------------
revno: 4762
revision-id: v.ladeuil+lp at free.fr-20091209150900-pbytmi9fh4fa3vbf
parent: v.ladeuil+lp at free.fr-20091209141848-enx8tnsb84wwq2bl
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 353370-notty-no-term-width
timestamp: Wed 2009-12-09 16:09:00 +0100
message:
  Fix broken test (fail on windows).
  
  * bzrlib/tests/test_osutils.py:
  (TestTerminalWidth.test_falls_back_to_COLUMNS): COLUMNS makes
  sense for ttys only.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2009-12-09 10:31:04 +0000
+++ b/bzrlib/tests/test_osutils.py	2009-12-09 15:09:00 +0000
@@ -1942,6 +1942,14 @@
         self.addCleanup(restore)
         osutils._terminal_size = new
 
+    def set_fake_tty(self):
+
+        class I_am_a_tty(object):
+            def isatty(self):
+                return True
+
+        self.replace_stdout(I_am_a_tty())
+
     def test_default_values(self):
         self.assertEqual(80, osutils.default_terminal_width)
 
@@ -1954,6 +1962,7 @@
     def test_falls_back_to_COLUMNS(self):
         del os.environ['BZR_COLUMNS']
         self.assertNotEqual('42', os.environ['COLUMNS'])
+        self.set_fake_tty()
         os.environ['COLUMNS'] = '42'
         self.assertEqual(42, osutils.terminal_width())
 
@@ -1961,14 +1970,10 @@
         del os.environ['BZR_COLUMNS']
         del os.environ['COLUMNS']
 
-        class I_am_a_tty(object):
-            def isatty(self):
-                return True
-
         def terminal_size(w, h):
             return 42, 42
 
-        self.replace_stdout(I_am_a_tty())
+        self.set_fake_tty()
         # We need to override the osutils definition as it depends on the
         # running environment that we can't control (PQM running without a
         # controlling terminal is one example).



More information about the bazaar-commits mailing list