Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create run_tests.py #8720

Merged
merged 16 commits into from
Dec 26, 2023
2 changes: 1 addition & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ jobs:
continue-on-error: False
run: |
python3 -m yt_dlp -v || true # Print debug head
python3 -Werror ./devscripts/run_tests.py core
python3 ./devscripts/run_tests.py core
4 changes: 2 additions & 2 deletions .github/workflows/download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: pip install pytest -r requirements.txt
- name: Run tests
continue-on-error: true
run: python3 -Werror ./devscripts/run_tests.py download
run: python3 ./devscripts/run_tests.py download

full:
name: Full Download Tests
Expand All @@ -45,4 +45,4 @@ jobs:
run: pip install pytest -r requirements.txt
- name: Run tests
continue-on-error: true
run: python3 -Werror ./devscripts/run_tests.py download
run: python3 ./devscripts/run_tests.py download
2 changes: 1 addition & 1 deletion .github/workflows/quick-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Run tests
run: |
python3 -m yt_dlp -v || true
python3 -Werror ./devscripts/run_tests.py core
python3 ./devscripts/run_tests.py core
flake8:
name: Linter
if: "!contains(github.event.head_commit.message, 'ci skip all')"
Expand Down
2 changes: 1 addition & 1 deletion devscripts/run_tests.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off

>&2 echo run_tests.bat is deprecated. Please use `devscripts/run_tests.py` instead
python -Werror %~dp0run_tests.py %~1
python %~dp0run_tests.py %~1
12 changes: 2 additions & 10 deletions devscripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import re
import subprocess
import sys
import warnings
from pathlib import Path


Expand All @@ -23,14 +22,11 @@ def parse_args():


def run_tests(*tests, pattern=None):
werror = ('error', None, Warning, None, 0) in warnings.filters
run_core = 'core' in tests or (not pattern and not tests)
run_download = 'download' in tests
tests = list(map(fix_test_name, tests))

arguments = ['pytest', '--tb', 'short']
if werror:
arguments.append('-Werror')
arguments = ['pytest', '-Werror', '--tb', 'short']
pukkandan marked this conversation as resolved.
Show resolved Hide resolved
if run_core:
arguments.extend(['-m', 'not download'])
elif run_download:
Expand All @@ -48,11 +44,7 @@ def run_tests(*tests, pattern=None):
except FileNotFoundError:
pass

arguments = [sys.executable]
if werror:
arguments.append('-Werror')
arguments.extend(['-m', 'unittest'])

arguments = [sys.executable, '-Werror', '-m', 'unittest']
if run_core:
print('"pytest" needs to be installed to run core tests', file=sys.stderr)
return
Expand Down
2 changes: 1 addition & 1 deletion devscripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh

>&2 echo 'run_tests.sh is deprecated. Please use `devscripts/run_tests.py` instead'
python3 -Werror devscripts/run_tests.py "$1"
python3 devscripts/run_tests.py "$1"