From 15ac9061cb0b516c4ddb8ec188e94bbbd672044e Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Mon, 14 Oct 2024 12:04:24 -0400 Subject: [PATCH 1/3] Add test framework --- .github/workflows/lint.yml | 4 +++- .github/workflows/test.yml | 42 ++++++++++++++++++++++++++++++++++++++ pytest.ini | 2 ++ requirements-dev.txt | 2 ++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml create mode 100644 pytest.ini 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..b3199db --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: Test Python code + +on: + push: + branches: + - master + paths: + - '**.py' + pull_request: + paths: + - '**.py' + +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..a635c5c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +pythonpath = . 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 From 56ebb885eecefc5f8fbfa6031d39cf0543667f53 Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Mon, 14 Oct 2024 14:25:39 -0400 Subject: [PATCH 2/3] testing do not merge yet --- .github/workflows/test.yml | 10 +--------- pytest.ini | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3199db..1392701 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,14 +1,6 @@ name: Test Python code -on: - push: - branches: - - master - paths: - - '**.py' - pull_request: - paths: - - '**.py' +on: [push, pull_request] jobs: windows: diff --git a/pytest.ini b/pytest.ini index a635c5c..03f586d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -pythonpath = . +pythonpath = . \ No newline at end of file From fa3a51f2529eea52a6e12e6d3e03bb4f6c40f44c Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Mon, 14 Oct 2024 14:34:39 -0400 Subject: [PATCH 3/3] lol --- tests/test_funcs.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/test_funcs.py 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)