Beispiel #1
0
 def test_with_detached_io_buffer(self):
     with io.StringIO() as stream:
         wrapper = io.TextIOWrapper(stream, 'UTF-8')
         if sys.version_info >= (2, 7):
             wrapper.detach()
             exc_type = ValueError if PYTHON else AttributeError
         else:
             wrapper.buffer = None
             exc_type = AttributeError
         assert_raises(exc_type, wrapper.isatty)
         assert_false(isatty(wrapper))
Beispiel #2
0
 def test_with_detached_io_buffer(self):
     with io.StringIO() as stream:
         wrapper = io.TextIOWrapper(stream, 'UTF-8')
         if sys.version_info >= (2, 7):
             wrapper.detach()
             exc_type = ValueError if PYTHON else AttributeError
         else:
             wrapper.buffer = None
             exc_type = AttributeError
         assert_raises(exc_type, wrapper.isatty)
         assert_false(isatty(wrapper))
Beispiel #3
0
 def test_isatty_with_detached_io_buffer(self):
     # make sure that isatty() checks for detached io stream buffers
     # (otherwise it would raise an Exception)
     with io.StringIO() as stream:
         wrapper = io.TextIOWrapper(stream)
         if sys.version_info >= (2, 7):
             wrapper.detach() #==> wrapper.buffer is None
             # Jython 2.7 behaves like CPython 2.6 in that case
             exc_type = ValueError if not JYTHON else AttributeError
         else: # no .detach and different behaviour if .buffer is None
             wrapper.buffer = None
             exc_type = AttributeError
         assert_raises(exc_type, wrapper.isatty)
         assert_false(isatty(wrapper))
Beispiel #4
0
 def test_with_io(self):
     with io.StringIO() as stream:
         assert_false(isatty(stream))
         wrapper = io.TextIOWrapper(stream, 'UTF-8')
         assert_false(isatty(wrapper))
Beispiel #5
0
 def test_with_stdout(self):
     # file class based in PY2, io module based in PY3
     assert_equals(isatty(sys.__stdout__), sys.__stdout__.isatty())
Beispiel #6
0
 def test_isatty_with_io(self):
     with io.StringIO() as stream:
         assert_false(isatty(stream))
         wrapper = io.TextIOWrapper(stream)
         assert_false(isatty(wrapper))
Beispiel #7
0
 def test_isatty_with_stdout(self):
     # file class based in PY2, io module based in PY3
     assert_equals(isatty(sys.__stdout__), sys.__stdout__.isatty())