diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 35d3610..17491c0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1392701 --- /dev/null +++ b/.github/workflows/test.yml @@ -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/github-action@v2.3.1 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..03f586d --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = . \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index a2f94d9..20e28d7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,5 @@ packaging>=24.0 pycodestyle>=2.11.1 +pytest>=7.3.1 +pytest-cov>=5.0.0 ruff>=0.6.5 diff --git a/tests/test_funcs.py b/tests/test_funcs.py new file mode 100644 index 0000000..a94a0ec --- /dev/null +++ b/tests/test_funcs.py @@ -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)