-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent file stream from being incorrectly wrapped on Pycharm
- Loading branch information
Showing
4 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Copyright Jonathan Hartley 2013. BSD 3-Clause license, see LICENSE file. | ||
import sys | ||
from unittest import TestCase, main | ||
|
||
from ..ansitowin32 import is_a_tty, AnsiToWin32 | ||
from .utils import pycharm, replace_by, replace_original_by, StreamTTY, StreamNonTTY | ||
|
||
|
||
class IsattyTest(TestCase): | ||
|
||
def test_TTY(self): | ||
tty = StreamTTY() | ||
self.assertTrue(is_a_tty(tty)) | ||
with pycharm(): | ||
self.assertTrue(is_a_tty(tty)) | ||
|
||
def test_nonTTY(self): | ||
non_tty = StreamNonTTY() | ||
self.assertFalse(is_a_tty(non_tty)) | ||
with pycharm(): | ||
self.assertFalse(is_a_tty(non_tty)) | ||
|
||
def test_withPycharm(self): | ||
with pycharm(): | ||
self.assertTrue(is_a_tty(sys.stderr)) | ||
self.assertTrue(is_a_tty(sys.stdout)) | ||
|
||
def test_withPycharmTTYOverride(self): | ||
tty = StreamTTY() | ||
with pycharm(), replace_by(tty): | ||
self.assertTrue(is_a_tty(tty)) | ||
|
||
def test_withPycharmNonTTYOverride(self): | ||
non_tty = StreamNonTTY() | ||
with pycharm(), replace_by(non_tty): | ||
self.assertFalse(is_a_tty(non_tty)) | ||
|
||
def test_withPycharmNoneOverride(self): | ||
with pycharm(): | ||
with replace_by(None), replace_original_by(None): | ||
self.assertFalse(is_a_tty(None)) | ||
self.assertFalse(is_a_tty(StreamNonTTY())) | ||
self.assertTrue(is_a_tty(StreamTTY())) | ||
|
||
def test_withPycharmStreamWrapped(self): | ||
with pycharm(): | ||
self.assertTrue(is_a_tty(AnsiToWin32(StreamTTY()).stream)) | ||
self.assertFalse(is_a_tty(AnsiToWin32(StreamNonTTY()).stream)) | ||
self.assertTrue(is_a_tty(AnsiToWin32(sys.stdout).stream)) | ||
self.assertTrue(is_a_tty(AnsiToWin32(sys.stderr).stream)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters