File: test_terminal_utils.py

package info (click to toggle)
ros-osrf-pycommon 2.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 360 kB
  • sloc: python: 1,726; makefile: 146; xml: 16
file content (17 lines) | stat: -rw-r--r-- 607 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import unittest
from unittest import mock

from osrf_pycommon.terminal_utils import is_tty


class TestTerminalUtils(unittest.TestCase):
    def test_is_tty(self):
        mock_stream = object()
        self.assertFalse(is_tty(mock_stream))
        mock_stream = mock.MagicMock()
        mock_stream.isatty = mock.MagicMock(return_value=None)
        self.assertFalse(is_tty(mock_stream))
        mock_stream.isatty = mock.MagicMock(return_value=False)
        self.assertFalse(is_tty(mock_stream))
        mock_stream.isatty = mock.MagicMock(return_value=True)
        self.assertTrue(is_tty(mock_stream))