add capability to suppress expected warnings in tests
This commit is contained in:
parent
e94b783c74
commit
00fcc17aee
3 changed files with 20 additions and 4 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue