Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys.stdout interface changes after wrapping #32

Closed
tartley opened this issue Feb 16, 2015 · 0 comments
Closed

sys.stdout interface changes after wrapping #32

tartley opened this issue Feb 16, 2015 · 0 comments

Comments

@tartley
Copy link
Owner

tartley commented Feb 16, 2015

Reported by [email protected], Feb 10 (5 days 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'
Feb 10 (5 days ago) #1 [email protected]
slight correction to code:

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

(Issue migrated from https://code.google.com/p/colorama/issues/detail?id=64)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant