Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
isatty_test.py
Go to the documentation of this file.
1# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file.
2import sys
3from unittest import TestCase, main
4
5from ..ansitowin32 import StreamWrapper, AnsiToWin32
6from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY
7
8
9def is_a_tty(stream):
10 return StreamWrapper(stream, None).isatty()
11
12class IsattyTest(TestCase):
13
14 def test_TTY(self):
15 tty = StreamTTY()
16 self.assertTrue(is_a_tty(tty))
17 with pycharm():
18 self.assertTrue(is_a_tty(tty))
19
20 def test_nonTTY(self):
21 non_tty = StreamNonTTY()
22 self.assertFalse(is_a_tty(non_tty))
23 with pycharm():
24 self.assertFalse(is_a_tty(non_tty))
25
27 with pycharm():
28 self.assertTrue(is_a_tty(sys.stderr))
29 self.assertTrue(is_a_tty(sys.stdout))
30
32 tty = StreamTTY()
33 with pycharm(), replace_by(tty):
34 self.assertTrue(is_a_tty(tty))
35
37 non_tty = StreamNonTTY()
38 with pycharm(), replace_by(non_tty):
39 self.assertFalse(is_a_tty(non_tty))
40
42 with pycharm():
43 with replace_by(None), replace_original_by(None):
44 self.assertFalse(is_a_tty(None))
45 self.assertFalse(is_a_tty(StreamNonTTY()))
46 self.assertTrue(is_a_tty(StreamTTY()))
47
49 with pycharm():
50 self.assertTrue(AnsiToWin32(StreamTTY()).stream.isatty())
51 self.assertFalse(AnsiToWin32(StreamNonTTY()).stream.isatty())
52 self.assertTrue(AnsiToWin32(sys.stdout).stream.isatty())
53 self.assertTrue(AnsiToWin32(sys.stderr).stream.isatty())
54
55
56if __name__ == '__main__':
57 main()
for i