diff options
author | Imran Hussain <ih@imranh.co.uk> | 2024-10-20 18:10:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-20 17:10:26 +0000 |
commit | 0f593dca9fa995d88eb763170a932da61c8f24dc (patch) | |
tree | 601f201d5981bb0b12b6a01e782be97849cc177e /test/test_plugins.py | |
parent | 8de431ec97a4b62b73df8f686b6e21e462775336 (diff) |
Add option `--plugin-dirs` (#11277)
Closes #3260
Authored by: imranh2, coletdjnz
Co-authored-by: coletdjnz <coletdjnz@protonmail.com>
Diffstat (limited to 'test/test_plugins.py')
-rw-r--r-- | test/test_plugins.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_plugins.py b/test/test_plugins.py index c82158e9f..77545d136 100644 --- a/test/test_plugins.py +++ b/test/test_plugins.py @@ -10,6 +10,7 @@ TEST_DATA_DIR = Path(os.path.dirname(os.path.abspath(__file__)), 'testdata') sys.path.append(str(TEST_DATA_DIR)) importlib.invalidate_caches() +from yt_dlp.utils import Config from yt_dlp.plugins import PACKAGE_NAME, directories, load_plugins @@ -68,6 +69,24 @@ class TestPlugins(unittest.TestCase): os.remove(zip_path) 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__': unittest.main() |