Skip to content

Commit

Permalink
Use pytest instead of setup.py test
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue authored Jul 31, 2024
1 parent b2193fd commit 582b230
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
with:
python-version: "3.12"

- name: Packages
run: pip install -r tests/requirements.txt

- name: Linters
run: make lint

Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ LDFLAGS ?= ""
CFLAGS ?= "-O0"

PYAV_PYTHON ?= python
PYAV_PIP ?= pip
PYTHON := $(PYAV_PYTHON)
PIP := $(PYAV_PIP)


.PHONY: default build clean fate-suite lint test
Expand All @@ -11,6 +13,8 @@ default: build


build:
# Always try to install the Python dependencies they are cheap.
$(PIP) install --upgrade -r tests/requirements.txt
CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) $(PYTHON) setup.py build_ext --inplace --debug

clean:
Expand All @@ -25,10 +29,12 @@ fate-suite:
rsync -vrltLW rsync://fate-suite.ffmpeg.org/fate-suite/ tests/assets/fate-suite/

lint:
$(PIP) install --upgrade -r tests/requirements.txt
black --check av examples tests setup.py
flake8 av examples tests
isort --check-only --diff av examples tests
mypy av tests

test:
$(PYTHON) setup.py test
$(PIP) install --upgrade -r tests/requirements.txt
$(PYTHON) -m pytest
9 changes: 6 additions & 3 deletions scripts/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ fi
export PYAV_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.."; pwd)"

if [[ ! "$PYAV_LIBRARY" ]]; then

# Pull from command line argument.
if [[ "$1" ]]; then
PYAV_LIBRARY="$1"
if [[ "$1" == ffmpeg-* ]]; then
PYAV_LIBRARY="$1"
else
echo "Error: PYAV_LIBRARY must start with 'ffmpeg-'" >&2
return 1
fi
else
PYAV_LIBRARY=ffmpeg-7.0.1
echo "No \$PYAV_LIBRARY set; defaulting to $PYAV_LIBRARY"
Expand Down
5 changes: 2 additions & 3 deletions scripts/build-deps
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ fi
cd "$PYAV_ROOT"

# Always try to install the Python dependencies they are cheap.
$PYAV_PIP install --upgrade -r tests/requirements.txt

$PYAV_PIP install --upgrade -r tests/requirements.txt 2> /dev/null

# Skip the rest of the build if it already exists.
if [[ -e "$PYAV_LIBRARY_PREFIX/bin/ffmpeg" ]]; then
echo "We have a cached build of $PYAV_LIBRARY; skipping re-build."
echo "We have a cached build of ffmpeg-$PYAV_LIBRARY; skipping re-build."
exit 0
fi

Expand Down
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ istest() {
}

if istest main; then
$PYAV_PYTHON setup.py test
$PYAV_PYTHON -m pytest
fi

if istest examples; then
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ black
isort
flake8
flake8-pyproject
pytest
sphinx==5.1.0
mypy==1.10.0

0 comments on commit 582b230

Please sign in to comment.