Exemple #1
0
 def _marking_enabled(self, markers, stdout):
     auto = utils.isatty(stdout)
     return {
         'AUTO': auto,
         'ON': True,
         'OFF': False
     }.get(markers.upper(), auto)
Exemple #2
0
 def test_with_detached_io_buffer(self):
     with io.StringIO() as stream:
         wrapper = io.TextIOWrapper(stream, 'UTF-8')
         wrapper.detach()
         exc_type = ValueError if PYTHON else AttributeError
         assert_raises(exc_type, wrapper.isatty)
         assert_false(isatty(wrapper))
Exemple #3
0
 def test_with_detached_io_buffer(self):
     with io.StringIO() as stream:
         wrapper = io.TextIOWrapper(stream, 'UTF-8')
         wrapper.detach()
         exc_type = ValueError if PYTHON else AttributeError
         assert_raises(exc_type, wrapper.isatty)
         assert_false(isatty(wrapper))
Exemple #4
0
 def _get_highlighter(self, stream, colors):
     auto = Highlighter if utils.isatty(stream) else NoHighlighting
     highlighter = {'AUTO': auto,
                    'ON': Highlighter,
                    'FORCE': Highlighter,   # compatibility with 2.5.5 and earlier
                    'OFF': NoHighlighting,
                    'ANSI': AnsiHighlighter}.get(colors.upper(), auto)
     return highlighter(stream)
Exemple #5
0
 def _get_highlighter(self, stream, colors):
     auto = Highlighter if utils.isatty(stream) else NoHighlighting
     highlighter = {'AUTO': auto,
                    'ON': Highlighter,
                    'FORCE': Highlighter,   # compatibility with 2.5.5 and earlier
                    'OFF': NoHighlighting,
                    'ANSI': AnsiHighlighter}.get(colors.upper(), auto)
     return highlighter(stream)
Exemple #6
0
 def _marking_enabled(self, markers, highlighter):
     options = {'AUTO': isatty(highlighter.stream),
                'ON': True,
                'OFF': False}
     try:
         return options[markers.upper()]
     except KeyError:
         raise DataError("Invalid console marker value '%s'. Available "
                         "'AUTO', 'ON' and 'OFF'." % markers)
 def _marking_enabled(self, markers, highlighter):
     options = {'AUTO': isatty(highlighter.stream),
                'ON': True,
                'OFF': False}
     try:
         return options[markers.upper()]
     except KeyError:
         raise DataError("Invalid console marker value '%s'. Available "
                         "'AUTO', 'ON' and 'OFF'." % markers)
Exemple #8
0
 def _get_highlighter(self, stream, colors):
     options = {'AUTO': Highlighter if isatty(stream) else NoHighlighting,
                'ON': Highlighter,
                'OFF': NoHighlighting,
                'ANSI': AnsiHighlighter}
     try:
         highlighter = options[colors.upper()]
     except KeyError:
         raise DataError("Invalid console color value '%s'. Available "
                         "'AUTO', 'ON', 'OFF' and 'ANSI'." % colors)
     return highlighter(stream)
 def _get_highlighter(self, stream, colors):
     options = {'AUTO': Highlighter if isatty(stream) else NoHighlighting,
                'ON': Highlighter,
                'OFF': NoHighlighting,
                'ANSI': AnsiHighlighter}
     try:
         highlighter = options[colors.upper()]
     except KeyError:
         raise DataError("Invalid console color value '%s'. Available "
                         "'AUTO', 'ON', 'OFF' and 'ANSI'." % colors)
     return highlighter(stream)
Exemple #10
0
 def test_with_stdout_and_stderr(self):
     # file class based in PY2, io module based in PY3
     assert_equals(isatty(sys.__stdout__), sys.__stdout__.isatty())
     assert_equals(isatty(sys.__stderr__), sys.__stderr__.isatty())
Exemple #11
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))
 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_stdout_and_stderr(self):
     # file class based in PY2, io module based in PY3
     assert_equal(isatty(sys.__stdout__), sys.__stdout__.isatty())
     assert_equal(isatty(sys.__stderr__), sys.__stderr__.isatty())
Exemple #14
0
 def _marking_enabled(self, markers, stdout):
     auto = utils.isatty(stdout)
     return {'AUTO': auto,
             'ON': True,
             'OFF': False}.get(markers.upper(), auto)
Exemple #15
0
 def test_open_and_closed_file(self):
     with open(__file__) as file:
         assert_false(isatty(file))
     assert_false(isatty(file))
Exemple #16
0
 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))
Exemple #17
0
 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_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 _marking_enabled(self, markers, highlighter):
     auto = isatty(highlighter.stream)
     return {'AUTO': auto,
             'ON': True,
             'OFF': False}.get(markers.upper(), auto)