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

Add test framework #104

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ jobs:
pip install -r requirements-dev.txt

- name: Running ruff
run: ruff check vsscale
run: |
ruff check vsscale
ruff check tests
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Test Python code

on: [push, pull_request]

jobs:
windows:
runs-on: windows-latest
strategy:
matrix:
vs-versions:
- 68
python-version:
- '3.12'

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install vapoursynth-portable==${{ matrix.vs-versions }}
pip install -r requirements.txt
pip install -r requirements-dev.txt

- name: Running tests
run: pytest --cov-report=term-missing:skip-covered --cov=vsscale tests

- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
pythonpath = .
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
packaging>=24.0
pycodestyle>=2.11.1
pytest>=7.3.1
pytest-cov>=5.0.0
ruff>=0.6.5
26 changes: 26 additions & 0 deletions tests/test_funcs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from unittest import TestCase

import vapoursynth as vs
from vskernels import Bicubic, Bilinear

from vsscale import MergeScalers


class TestFuncs(TestCase):
def test_merge_scalers_downscale(self) -> None:
input = vs.core.std.BlankClip(width=1920, height=1080, format=vs.YUV420P8)
scaler = MergeScalers((Bicubic, 0.5), (Bilinear, 0.5))
output = scaler.scale(input, 1280, 720)
self.assertEqual(output.width, 1280)
self.assertEqual(output.height, 720)
self.assertEqual(output.format.color_family, vs.YUV)
self.assertEqual(output.format.bits_per_sample, 8)

def test_merge_scalers_upscale(self) -> None:
input = vs.core.std.BlankClip(width=1280, height=720, format=vs.YUV420P8)
scaler = MergeScalers((Bicubic, 0.5), (Bilinear, 0.5))
output = scaler.scale(input, 1920, 1080)
self.assertEqual(output.width, 1920)
self.assertEqual(output.height, 1080)
self.assertEqual(output.format.color_family, vs.YUV)
self.assertEqual(output.format.bits_per_sample, 8)
Loading