aboutsummaryrefslogtreecommitdiff
path: root/test/helper.py
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo.valsorda@gmail.com>2013-10-28 18:03:26 -0400
committerFilippo Valsorda <filippo.valsorda@gmail.com>2013-10-28 18:03:26 -0400
commitdd508b7c4f0dd8881de07a4e8593d4fcdef9bae7 (patch)
treee6b2f70bba9f9a4709e15dd64cfd10c70aab70b6 /test/helper.py
parent2563bcc85cc09382d7e731709b2c8a4ad96c7ea3 (diff)
[tests] don't fail on network errors
This is suboptimal, but at least this way we will need to look at the logs only to check for network errors that happen too often, instead of parsing a ton of lines each time to see if there is some true test failing
Diffstat (limited to 'test/helper.py')
-rw-r--r--test/helper.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/helper.py b/test/helper.py
index 777119ea5..d7bf7a828 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -5,9 +5,11 @@ import json
import os.path
import re
import types
+import sys
import youtube_dl.extractor
from youtube_dl import YoutubeDL
+from youtube_dl.utils import preferredencoding
def global_setup():
@@ -33,6 +35,21 @@ def try_rm(filename):
raise
+def report_warning(message):
+ '''
+ Print the message to stderr, it will be prefixed with 'WARNING:'
+ If stderr is a tty file the 'WARNING:' will be colored
+ '''
+ if sys.stderr.isatty() and os.name != 'nt':
+ _msg_header = u'\033[0;33mWARNING:\033[0m'
+ else:
+ _msg_header = u'WARNING:'
+ output = u'%s %s\n' % (_msg_header, message)
+ if 'b' in getattr(sys.stderr, 'mode', '') or sys.version_info[0] < 3:
+ output = output.encode(preferredencoding())
+ sys.stderr.write(output)
+
+
class FakeYDL(YoutubeDL):
def __init__(self, override=None):
# Different instances of the downloader can't share the same dictionary