diff --git a/test/test_plugins.py b/test/test_plugins.py index 6d0b7ac839..af4b77dabf 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -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() diff --git a/test/testdata/yt_dlp_plugins/extractor/override.py b/test/testdata/yt_dlp_plugins/extractor/override.py new file mode 100644 index 0000000000..766dc32e14 --- /dev/null +++ b/test/testdata/yt_dlp_plugins/extractor/override.py @@ -0,0 +1,5 @@ +from yt_dlp.extractor.generic import GenericIE + + +class OverrideGenericIE(GenericIE, plugin_name='override'): + TEST_FIELD = 'override' diff --git a/test/testdata/yt_dlp_plugins/extractor/overridetwo.py b/test/testdata/yt_dlp_plugins/extractor/overridetwo.py new file mode 100644 index 0000000000..826184c642 --- /dev/null +++ b/test/testdata/yt_dlp_plugins/extractor/overridetwo.py @@ -0,0 +1,5 @@ +from yt_dlp.extractor.generic import GenericIE + + +class _UnderscoreOverrideGenericIE(GenericIE, plugin_name='underscore-override'): + SECONDARY_TEST_FIELD = 'underscore-override'