|
|
@ -10,6 +10,7 @@ TEST_DATA_DIR = Path(os.path.dirname(os.path.abspath(__file__)), 'testdata')
|
|
|
|
sys.path.append(str(TEST_DATA_DIR))
|
|
|
|
sys.path.append(str(TEST_DATA_DIR))
|
|
|
|
importlib.invalidate_caches()
|
|
|
|
importlib.invalidate_caches()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from yt_dlp.utils import Config
|
|
|
|
from yt_dlp.plugins import PACKAGE_NAME, directories, load_plugins
|
|
|
|
from yt_dlp.plugins import PACKAGE_NAME, directories, load_plugins
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -68,6 +69,24 @@ class TestPlugins(unittest.TestCase):
|
|
|
|
os.remove(zip_path)
|
|
|
|
os.remove(zip_path)
|
|
|
|
importlib.invalidate_caches() # reset the import caches
|
|
|
|
importlib.invalidate_caches() # reset the import caches
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_plugin_dirs(self):
|
|
|
|
|
|
|
|
# Internal plugin dirs hack for CLI --plugin-dirs
|
|
|
|
|
|
|
|
# To be replaced with proper system later
|
|
|
|
|
|
|
|
custom_plugin_dir = TEST_DATA_DIR / 'plugin_packages'
|
|
|
|
|
|
|
|
Config._plugin_dirs = [str(custom_plugin_dir)]
|
|
|
|
|
|
|
|
importlib.invalidate_caches() # reset the import caches
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
package = importlib.import_module(f'{PACKAGE_NAME}.extractor')
|
|
|
|
|
|
|
|
self.assertIn(custom_plugin_dir / 'testpackage' / PACKAGE_NAME / 'extractor', map(Path, package.__path__))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plugins_ie = load_plugins('extractor', 'IE')
|
|
|
|
|
|
|
|
self.assertIn('PackagePluginIE', plugins_ie.keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
finally:
|
|
|
|
|
|
|
|
Config._plugin_dirs = []
|
|
|
|
|
|
|
|
importlib.invalidate_caches() # reset the import caches
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
unittest.main()
|
|
|
|