Add test for override plugins

This commit is contained in:
coletdjnz 2024-10-19 17:30:53 +13:00
parent 6547ff4335
commit 42771dde1c
No known key found for this signature in database
GPG key ID: 91984263BB39894A
3 changed files with 27 additions and 0 deletions

View file

@ -43,6 +43,10 @@ class TestPlugins(unittest.TestCase):
self.assertNotIn('IgnoreNotInAllPluginIE', plugins_ie.keys())
self.assertIn('InAllPluginIE', plugins_ie.keys())
# Don't load override extractors into plugins_ie
self.assertNotIn('OverrideGenericIE', plugins_ie.keys())
self.assertNotIn('_UnderscoreOverrideGenericIE', plugins_ie.keys())
def test_postprocessor_classes(self):
plugins_pp = load_plugins(PluginType.POSTPROCESSORS)
self.assertIn('NormalPluginPP', plugins_pp.keys())
@ -108,6 +112,19 @@ class TestPlugins(unittest.TestCase):
sys.path.append(str(TEST_DATA_DIR))
importlib.invalidate_caches()
def test_extractor_override_plugin(self):
for module_name in tuple(sys.modules):
if module_name.startswith(f'{PACKAGE_NAME}.extractor'):
del sys.modules[module_name]
plugins_ie = load_plugins(PluginType.EXTRACTORS)
from yt_dlp.extractor.generic import GenericIE
self.assertEqual(GenericIE.TEST_FIELD, 'override')
self.assertEqual(GenericIE.SECONDARY_TEST_FIELD, 'underscore-override')
self.assertEqual(GenericIE.IE_NAME, 'generic+override+underscore-override')
if __name__ == '__main__':
unittest.main()

View file

@ -0,0 +1,5 @@
from yt_dlp.extractor.generic import GenericIE
class OverrideGenericIE(GenericIE, plugin_name='override'):
TEST_FIELD = 'override'

View file

@ -0,0 +1,5 @@
from yt_dlp.extractor.generic import GenericIE
class _UnderscoreOverrideGenericIE(GenericIE, plugin_name='underscore-override'):
SECONDARY_TEST_FIELD = 'underscore-override'