mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-07-09 14:58:32 +00:00
add --plugins
Co-authored-by: Simon Sawicki <37424085+Grub4K@users.noreply.github.com>
This commit is contained in:
parent
741fd809bc
commit
9c771dd218
@ -19,12 +19,14 @@ def parse_args():
|
|||||||
'test', help='an extractor test, test path, or one of "core" or "download"', nargs='*')
|
'test', help='an extractor test, test path, or one of "core" or "download"', nargs='*')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-k', help='run a test matching EXPRESSION. Same as "pytest -k"', metavar='EXPRESSION')
|
'-k', help='run a test matching EXPRESSION. Same as "pytest -k"', metavar='EXPRESSION')
|
||||||
|
parser.add_argument(
|
||||||
|
'--plugins', help='load plugins', action='store_true')
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--pytest-args', help='arguments to passthrough to pytest')
|
'--pytest-args', help='arguments to passthrough to pytest')
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def run_tests(*tests, pattern=None, ci=False):
|
def run_tests(*tests, pattern=None, ci=False, load_plugins=False):
|
||||||
# XXX: hatch uses `tests` if no arguments are passed
|
# XXX: hatch uses `tests` if no arguments are passed
|
||||||
run_core = 'core' in tests or 'tests' in tests or (not pattern and not tests)
|
run_core = 'core' in tests or 'tests' in tests or (not pattern and not tests)
|
||||||
run_download = 'download' in tests
|
run_download = 'download' in tests
|
||||||
@ -47,7 +49,10 @@ def run_tests(*tests, pattern=None, ci=False):
|
|||||||
|
|
||||||
print(f'Running {arguments}', flush=True)
|
print(f'Running {arguments}', flush=True)
|
||||||
try:
|
try:
|
||||||
return subprocess.call(arguments)
|
return subprocess.call(arguments, env={
|
||||||
|
**os.environ,
|
||||||
|
'YTDLP_NO_PLUGINS': '1' if os.environ.get('YTDLP_NO_PLUGINS') or not load_plugins else '',
|
||||||
|
})
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -72,6 +77,6 @@ def run_tests(*tests, pattern=None, ci=False):
|
|||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
os.chdir(Path(__file__).parent.parent)
|
os.chdir(Path(__file__).parent.parent)
|
||||||
sys.exit(run_tests(*args.test, pattern=args.k, ci=bool(os.getenv('CI'))))
|
sys.exit(run_tests(*args.test, pattern=args.k, ci=bool(os.getenv('CI')), load_plugins=args.plugins))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
@ -87,6 +87,8 @@ def report_warning(self, message, *args, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def gettestcases(include_onlymatching=False):
|
def gettestcases(include_onlymatching=False):
|
||||||
|
import yt_dlp.plugins
|
||||||
|
yt_dlp.plugins.load_all_plugins()
|
||||||
for ie in yt_dlp.extractor.gen_extractors():
|
for ie in yt_dlp.extractor.gen_extractors():
|
||||||
yield from ie.get_testcases(include_onlymatching)
|
yield from ie.get_testcases(include_onlymatching)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user