forked from robotframework/robotframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_compat.py
More file actions
35 lines (26 loc) · 1.03 KB
/
Copy pathtest_compat.py
File metadata and controls
35 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import io
import sys
import unittest
from robot.utils import isatty
from robot.utils.asserts import assert_equal, assert_false, assert_raises
class TestIsATty(unittest.TestCase):
def test_with_stdout_and_stderr(self):
assert_equal(isatty(sys.__stdout__), sys.__stdout__.isatty())
assert_equal(isatty(sys.__stderr__), sys.__stderr__.isatty())
def test_with_io(self):
with io.StringIO() as stream:
assert_false(isatty(stream))
wrapper = io.TextIOWrapper(stream, 'UTF-8')
assert_false(isatty(wrapper))
def test_with_detached_io_buffer(self):
with io.StringIO() as stream:
wrapper = io.TextIOWrapper(stream, 'UTF-8')
wrapper.detach()
assert_raises((ValueError, AttributeError), wrapper.isatty)
assert_false(isatty(wrapper))
def test_open_and_closed_file(self):
with open(__file__) as file:
assert_false(isatty(file))
assert_false(isatty(file))
if __name__ == '__main__':
unittest.main()