-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix output stream failures (Windows) (#4375)
* POC of removing tqdm * iteration over IOError for stream output * added comments and test * commenting out test * trying a different import
- Loading branch information
1 parent
256c147
commit 0b7b3ca
Showing
3 changed files
with
49 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# coding=utf-8 | ||
|
||
import unittest | ||
from types import MethodType | ||
|
||
from six import StringIO | ||
|
||
from conans.client.output import ConanOutput | ||
from mock import mock | ||
|
||
|
||
class ConanOutputTest(unittest.TestCase): | ||
|
||
def test_blocked_output(self): | ||
# https://github.com/conan-io/conan/issues/4277 | ||
stream = StringIO() | ||
|
||
def write_raise(self, data): | ||
write_raise.counter = getattr(write_raise, "counter", 0) + 1 | ||
if write_raise.counter < 2: | ||
raise IOError("Stdout locked") | ||
self.super_write(data) | ||
stream.super_write = stream.write | ||
stream.write = MethodType(write_raise, stream) | ||
out = ConanOutput(stream) | ||
|
||
with mock.patch("time.sleep") as sleep: | ||
out.write("Hello world") | ||
sleep.assert_any_call(0.02) | ||
self.assertEqual("Hello world", stream.getvalue()) |
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