1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-12-20 06:58:57 +00:00

jsi override

This commit is contained in:
c-basalt
2025-05-17 10:18:59 -04:00
parent d74f921e37
commit f058874929
6 changed files with 69 additions and 8 deletions

View File

@@ -124,6 +124,11 @@ class TestPlugins(unittest.TestCase):
self.assertIn(f'{PACKAGE_NAME}.jsinterp.normal', sys.modules.keys())
self.assertIn('NormalPluginJSI', plugin_jsis.value)
self.assertNotIn('OverrideDenoJSI', plugins_jsi.keys())
self.assertNotIn('OverrideDenoJSI', plugin_jsis.value)
self.assertNotIn('_UnderscoreOverrideDenoJSI', plugins_jsi.keys())
self.assertNotIn('_UnderscoreOverrideDenoJSI', plugin_jsis.value)
def test_importing_zipped_module(self):
zip_path = TEST_DATA_DIR / 'zipped_plugins.zip'
shutil.make_archive(str(zip_path)[:-4], 'zip', str(zip_path)[:-4])
@@ -209,6 +214,24 @@ class TestPlugins(unittest.TestCase):
from yt_dlp.extractor.generic import GenericIE
self.assertEqual(GenericIE.IE_NAME, 'generic+override+underscore-override')
def test_jsi_override_plugin(self):
load_plugins(JSI_PLUGIN_SPEC)
from yt_dlp.jsinterp._deno import DenoJSI
# test that jsi_runtimes is updated with override jsi
self.assertTrue(DenoJSI is jsi_runtimes.value['Deno'])
self.assertEqual(jsi_runtimes.value['Deno'].TEST_FIELD, 'override')
self.assertEqual(jsi_runtimes.value['Deno'].SECONDARY_TEST_FIELD, 'underscore-override')
self.assertEqual(jsi_runtimes.value['Deno'].JSI_NAME, 'Deno+override+underscore-override')
importlib.invalidate_caches()
# test that loading a second time doesn't wrap a second time
load_plugins(EXTRACTOR_PLUGIN_SPEC)
from yt_dlp.jsinterp._deno import DenoJSI
self.assertTrue(DenoJSI is jsi_runtimes.value['Deno'])
self.assertEqual(jsi_runtimes.value['Deno'].JSI_NAME, 'Deno+override+underscore-override')
def test_load_all_plugin_types(self):
# no plugin specs registered