mirror of
https://github.com/beetbox/beets.git
synced 2025-12-26 02:24:33 +01:00
Fallback encoding under test harness
Now this works when capturing output for the tests.
This commit is contained in:
parent
649a0111d6
commit
8fdf995ff9
1 changed files with 5 additions and 0 deletions
|
|
@ -80,6 +80,11 @@ def _out_encoding():
|
|||
if encoding:
|
||||
return encoding
|
||||
|
||||
# For testing: When sys.stdout is a StringIO under the test harness,
|
||||
# it doesn't have an `encodiing` attribute. Just use UTF-8.
|
||||
if not hasattr(sys.stdout, 'encoding'):
|
||||
return 'utf8'
|
||||
|
||||
# Python's guessed output stream encoding, or UTF-8 as a fallback
|
||||
# (e.g., when piped to a file).
|
||||
return sys.stdout.encoding or 'utf8'
|
||||
|
|
|
|||
Loading…
Reference in a new issue