mirror of
https://github.com/beetbox/beets.git
synced 2026-01-30 12:02:41 +01:00
check for encoding attr before set in test_helper
This makes it work equivalently in py2 and py3
This commit is contained in:
parent
133c82b1ab
commit
4c98edc588
1 changed files with 4 additions and 2 deletions
|
|
@ -89,7 +89,8 @@ def control_stdin(input=None):
|
|||
"""
|
||||
org = sys.stdin
|
||||
sys.stdin = StringIO(input)
|
||||
sys.stdin.encoding = 'utf8'
|
||||
if hasattr(sys.stdin, 'encoding'):
|
||||
sys.stdin.encoding = 'utf8'
|
||||
try:
|
||||
yield sys.stdin
|
||||
finally:
|
||||
|
|
@ -108,7 +109,8 @@ def capture_stdout():
|
|||
"""
|
||||
org = sys.stdout
|
||||
sys.stdout = capture = StringIO()
|
||||
sys.stdout.encoding = 'utf8'
|
||||
if not hasattr(sys.stdout, 'encoding'):
|
||||
sys.stdout.encoding = 'utf8'
|
||||
try:
|
||||
yield sys.stdout
|
||||
finally:
|
||||
|
|
|
|||
Loading…
Reference in a new issue