From 52fadd5fb2ea5d7e7cd6000203aa7ef886ffad07 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Sat, 19 Apr 2014 19:41:06 +0200 Subject: [test_all_urls] Add support for distributed URL matching test definition --- test/helper.py | 14 ++++++++++---- test/test_all_urls.py | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/helper.py b/test/helper.py index 8739f816c..09873aea3 100644 --- a/test/helper.py +++ b/test/helper.py @@ -74,13 +74,19 @@ class FakeYDL(YoutubeDL): old_report_warning(message) self.report_warning = types.MethodType(report_warning, self) -def gettestcases(): + +def gettestcases(include_onlymatching=False): for ie in youtube_dl.extractor.gen_extractors(): t = getattr(ie, '_TEST', None) if t: - t['name'] = type(ie).__name__[:-len('IE')] - yield t - for t in getattr(ie, '_TESTS', []): + assert not hasattr(ie, '_TESTS'), \ + '%s has _TEST and _TESTS' % type(ie).__name__ + tests = [t] + else: + tests = getattr(ie, '_TESTS', []) + for t in tests: + if not include_onlymatching and getattr(t, 'only_matching', False): + continue t['name'] = type(ie).__name__[:-len('IE')] yield t diff --git a/test/test_all_urls.py b/test/test_all_urls.py index a9c4ed9e3..4b56137ce 100644 --- a/test/test_all_urls.py +++ b/test/test_all_urls.py @@ -106,7 +106,7 @@ class TestAllURLsMatching(unittest.TestCase): def test_no_duplicates(self): ies = gen_extractors() - for tc in gettestcases(): + for tc in gettestcases(include_onlymatching=True): url = tc['url'] for ie in ies: if type(ie).__name__ in ('GenericIE', tc['name'] + 'IE'): @@ -176,5 +176,6 @@ class TestAllURLsMatching(unittest.TestCase): 'https://screen.yahoo.com/smartwatches-latest-wearable-gadgets-163745379-cbs.html', ['Yahoo']) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3