Example #1
0
    def test_no_curses(self):
        # Make sure the patch works.
        with self.assertRaises(ImportError):
            misc_utils.import_curses()

        # Test functions that would require curses.
        self.assertEqual(0, misc_utils.get_screen_width())
        self.assertEqual(0, misc_utils.get_screen_height())
Example #2
0
    def get_pager(self):
        """Create and return a context manager to write to, a pager subprocess if required.

        Returns:
          A context manager.

        """
        if self.is_interactive:
            return pager.ConditionalPager(
                self.vars.get('pager', None),
                minlines=misc_utils.get_screen_height())
        return pager.flush_only(sys.stdout)
Example #3
0
    def get_pager(self):
        """Create and return a context manager to write to, a pager subprocess if required.

        Returns:
          A pair of a file object to write to, and a pipe object to wait on (or
        None if not necessary to wait).
        """
        if self.is_interactive:
            return pager.ConditionalPager(
                self.vars.get('pager', None),
                minlines=misc_utils.get_screen_height())
        file = (codecs.getwriter("utf-8")(sys.stdout.buffer) if hasattr(
            sys.stdout, 'buffer') else sys.stdout)
        return pager.flush_only(file)
Example #4
0
 def test_get_screen_height(self):
     max_height = misc_utils.get_screen_height()
     self.assertTrue(type(int), max_height)
     # Note: Allow zero because the console function fails in nose when
     # capture is disabled.
     self.assertLess(-1, max_height)