nghung270192 / colorama

Automatically exported from code.google.com/p/colorama
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

sys.stdout interface changes after wrapping #64

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Somewhat related to Issue 41, but if you have replaced sys.stdout with 
something else (like StringIO in order to capture output for unit testing 
purposes), then the wrapping that colorama does exposes an interface that 
differs from that of the object you set sys.stdout to.  Namely in the case of 
StringIO, it has a getvalue() method to get what was written to it.

After calling colorama.init, the object set to sys.stdout no longer has this 
method.

What steps will reproduce the problem?
1. set sys.stdio=StringIO
2. call colorama.init(strip=True,convert=False)
3. try to call sys.stdio.getvalue()

What is the expected output? 
An empty string on the console.

What do you see instead?
An error message about sys.stdio not having a 'getvalue' method.

What version of the product are you using? On what operating system?
'0.2.5'

Original issue reported on code.google.com by wbax...@google.com on 10 Feb 2015 at 9:53

GoogleCodeExporter commented 9 years ago
slight correction to code:

import StringIO
import sys
import colorama
sys.stdout = StringIO.StringIO()
colorama.init(strip=True, convert=False)
sys.stdout.getvalue()

Original comment by wbax...@google.com on 10 Feb 2015 at 9:55

GoogleCodeExporter commented 9 years ago
I have migrated this issue to the new github issues list:
https://github.com/tartley/colorama/issues/32

Original comment by jonathan...@made.com on 16 Feb 2015 at 11:17

GoogleCodeExporter commented 9 years ago

Original comment by tart...@gmail.com on 16 Feb 2015 at 11:18