aboutsummaryrefslogtreecommitdiff
path: root/test/helper.py
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo.valsorda@gmail.com>2013-10-05 15:55:58 -0400
committerFilippo Valsorda <filippo.valsorda@gmail.com>2013-10-05 15:55:58 -0400
commit00fcc17aeeab11ce694699bf183d33a3af75aab6 (patch)
tree2648e538ae2decba9b8eabf2da73101c1d38954e /test/helper.py
parente94b783c741b720ab4ee70eb7fc8764be89d63d5 (diff)
add capability to suppress expected warnings in tests
Diffstat (limited to 'test/helper.py')
-rw-r--r--test/helper.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/helper.py b/test/helper.py
index a2b468b50..63f56841f 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -1,6 +1,8 @@
import io
import json
import os.path
+import re
+import types
import youtube_dl.extractor
from youtube_dl import YoutubeDL, YoutubeDLHandler
@@ -32,6 +34,19 @@ class FakeYDL(YoutubeDL):
raise Exception(s)
def download(self, x):
self.result.append(x)
+ # def expect_warning(self, regex):
+ # # Silence an expected warning matching a regex
+ # def report_warning(self, message):
+ # if re.match(regex, message): return
+ # super(FakeYDL, self).report_warning(regex)
+ # self.report_warning = types.MethodType(report_warning, self)
+ def expect_warning(self, regex):
+ # Silence an expected warning matching a regex
+ old_report_warning = self.report_warning
+ def report_warning(self, message):
+ if re.match(regex, message): return
+ old_report_warning(message)
+ self.report_warning = types.MethodType(report_warning, self)
def get_testcases():
for ie in youtube_dl.extractor.gen_extractors():