forked from bugy/script-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugy#223: fixed an error on reading huge unicode outputs
- Loading branch information
Showing
3 changed files
with
47 additions
and
6 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
Empty file.
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,30 @@ | ||
import threading | ||
import unittest | ||
|
||
from execution.process_pty import PtyProcessWrapper | ||
from react.observable import read_until_closed | ||
from tests import test_utils | ||
|
||
|
||
class TestPtyProcessWrapper(unittest.TestCase): | ||
def test_many_unicode_characters(self): | ||
long_unicode_text = ('ΩΨΔ\n' * 100000) | ||
test_utils.create_file('test.txt', text=long_unicode_text) | ||
|
||
process_wrapper = PtyProcessWrapper(['cat', 'test.txt'], test_utils.temp_folder) | ||
process_wrapper.start() | ||
|
||
thread = threading.Thread(target=process_wrapper.wait_finish, daemon=True) | ||
thread.start() | ||
thread.join(timeout=0.1) | ||
|
||
output = ''.join(read_until_closed(process_wrapper.output_stream)) | ||
self.assertEqual(long_unicode_text, output) | ||
|
||
self.assertEqual(0, process_wrapper.get_return_code()) | ||
|
||
def setUp(self): | ||
test_utils.setup() | ||
|
||
def tearDown(self): | ||
test_utils.cleanup() |