mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[test_all_urls] Add support for distributed URL matching test definition
This commit is contained in:
		| @@ -74,13 +74,19 @@ class FakeYDL(YoutubeDL): | |||||||
|             old_report_warning(message) |             old_report_warning(message) | ||||||
|         self.report_warning = types.MethodType(report_warning, self) |         self.report_warning = types.MethodType(report_warning, self) | ||||||
|  |  | ||||||
| def gettestcases(): |  | ||||||
|  | def gettestcases(include_onlymatching=False): | ||||||
|     for ie in youtube_dl.extractor.gen_extractors(): |     for ie in youtube_dl.extractor.gen_extractors(): | ||||||
|         t = getattr(ie, '_TEST', None) |         t = getattr(ie, '_TEST', None) | ||||||
|         if t: |         if t: | ||||||
|             t['name'] = type(ie).__name__[:-len('IE')] |             assert not hasattr(ie, '_TESTS'), \ | ||||||
|             yield t |                 '%s has _TEST and _TESTS' % type(ie).__name__ | ||||||
|         for t in getattr(ie, '_TESTS', []): |             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')] |             t['name'] = type(ie).__name__[:-len('IE')] | ||||||
|             yield t |             yield t | ||||||
|  |  | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ class TestAllURLsMatching(unittest.TestCase): | |||||||
|  |  | ||||||
|     def test_no_duplicates(self): |     def test_no_duplicates(self): | ||||||
|         ies = gen_extractors() |         ies = gen_extractors() | ||||||
|         for tc in gettestcases(): |         for tc in gettestcases(include_onlymatching=True): | ||||||
|             url = tc['url'] |             url = tc['url'] | ||||||
|             for ie in ies: |             for ie in ies: | ||||||
|                 if type(ie).__name__ in ('GenericIE', tc['name'] + 'IE'): |                 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', |             'https://screen.yahoo.com/smartwatches-latest-wearable-gadgets-163745379-cbs.html', | ||||||
|             ['Yahoo']) |             ['Yahoo']) | ||||||
|  |  | ||||||
|  |  | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ from ..utils import ( | |||||||
|  |  | ||||||
| class ExtremeTubeIE(InfoExtractor): | class ExtremeTubeIE(InfoExtractor): | ||||||
|     _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>extremetube\.com/.*?video/.+?(?P<videoid>[0-9]+))(?:[/?&]|$)' |     _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>extremetube\.com/.*?video/.+?(?P<videoid>[0-9]+))(?:[/?&]|$)' | ||||||
|     _TEST = { |     _TESTS = [{ | ||||||
|         u'url': u'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431', |         u'url': u'http://www.extremetube.com/video/music-video-14-british-euro-brit-european-cumshots-swallow-652431', | ||||||
|         u'file': u'652431.mp4', |         u'file': u'652431.mp4', | ||||||
|         u'md5': u'1fb9228f5e3332ec8c057d6ac36f33e0', |         u'md5': u'1fb9228f5e3332ec8c057d6ac36f33e0', | ||||||
| @@ -19,7 +19,10 @@ class ExtremeTubeIE(InfoExtractor): | |||||||
|             u"uploader": u"unknown", |             u"uploader": u"unknown", | ||||||
|             u"age_limit": 18, |             u"age_limit": 18, | ||||||
|         } |         } | ||||||
|     } |     }, { | ||||||
|  |         'url': 'http://www.extremetube.com/gay/video/abcde-1234', | ||||||
|  |         'only_matching': True, | ||||||
|  |     }] | ||||||
|  |  | ||||||
|     def _real_extract(self, url): |     def _real_extract(self, url): | ||||||
|         mobj = re.match(self._VALID_URL, url) |         mobj = re.match(self._VALID_URL, url) | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ class OneUPIE(IGNIE): | |||||||
|  |  | ||||||
|     _DESCRIPTION_RE = r'<div id="vid_summary">(.+?)</div>' |     _DESCRIPTION_RE = r'<div id="vid_summary">(.+?)</div>' | ||||||
|  |  | ||||||
|     _TEST = { |     _TESTS = [{ | ||||||
|         'url': 'http://gamevideos.1up.com/video/id/34976', |         'url': 'http://gamevideos.1up.com/video/id/34976', | ||||||
|         'md5': '68a54ce4ebc772e4b71e3123d413163d', |         'md5': '68a54ce4ebc772e4b71e3123d413163d', | ||||||
|         'info_dict': { |         'info_dict': { | ||||||
| @@ -115,10 +115,7 @@ class OneUPIE(IGNIE): | |||||||
|             'title': 'Sniper Elite V2 - Trailer', |             'title': 'Sniper Elite V2 - Trailer', | ||||||
|             'description': 'md5:5d289b722f5a6d940ca3136e9dae89cf', |             'description': 'md5:5d289b722f5a6d940ca3136e9dae89cf', | ||||||
|         } |         } | ||||||
|     } |     }] | ||||||
|  |  | ||||||
|     # Override IGN tests |  | ||||||
|     _TESTS = [] |  | ||||||
|  |  | ||||||
|     def _real_extract(self, url): |     def _real_extract(self, url): | ||||||
|         mobj = re.match(self._VALID_URL, url) |         mobj = re.match(self._VALID_URL, url) | ||||||
|   | |||||||
| @@ -104,7 +104,7 @@ class YahooNewsIE(YahooIE): | |||||||
|     IE_NAME = 'yahoo:news' |     IE_NAME = 'yahoo:news' | ||||||
|     _VALID_URL = r'http://news\.yahoo\.com/video/.*?-(?P<id>\d*?)\.html' |     _VALID_URL = r'http://news\.yahoo\.com/video/.*?-(?P<id>\d*?)\.html' | ||||||
|  |  | ||||||
|     _TEST = { |     _TESTS = [{ | ||||||
|         'url': 'http://news.yahoo.com/video/china-moses-crazy-blues-104538833.html', |         'url': 'http://news.yahoo.com/video/china-moses-crazy-blues-104538833.html', | ||||||
|         'md5': '67010fdf3a08d290e060a4dd96baa07b', |         'md5': '67010fdf3a08d290e060a4dd96baa07b', | ||||||
|         'info_dict': { |         'info_dict': { | ||||||
| @@ -113,10 +113,7 @@ class YahooNewsIE(YahooIE): | |||||||
|             'title': 'China Moses Is Crazy About the Blues', |             'title': 'China Moses Is Crazy About the Blues', | ||||||
|             'description': 'md5:9900ab8cd5808175c7b3fe55b979bed0', |             'description': 'md5:9900ab8cd5808175c7b3fe55b979bed0', | ||||||
|         }, |         }, | ||||||
|     } |     }] | ||||||
|  |  | ||||||
|     # Overwrite YahooIE properties we don't want |  | ||||||
|     _TESTS = [] |  | ||||||
|  |  | ||||||
|     def _real_extract(self, url): |     def _real_extract(self, url): | ||||||
|         mobj = re.match(self._VALID_URL, url) |         mobj = re.match(self._VALID_URL, url) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Philipp Hagemeister
					Philipp Hagemeister