diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6667f83..70f304c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,11 +17,16 @@ permissions: jobs: run: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + runs-on: ${{ matrix.os }} steps: - name: Check out repository uses: actions/checkout@v4 - name: Set up MKVToolNix repository + if: matrix.os == 'ubuntu-latest' run: | sudo apt-get -qq update sudo apt-get -qq install -y wget gnupg @@ -29,19 +34,34 @@ jobs: UBUNTU_CODENAME=$(lsb_release -cs) echo "deb [arch=amd64 signed-by=/usr/share/keyrings/gpg-pub-moritzbunkus.gpg] https://mkvtoolnix.download/ubuntu/ $UBUNTU_CODENAME main" | sudo tee /etc/apt/sources.list.d/mkvtoolnix.list sudo apt-get -qq update - - name: Install MKVToolNix + - name: Install MKVToolNix (Ubuntu) + if: matrix.os == 'ubuntu-latest' run: sudo apt-get -qq install -y mkvtoolnix mkvtoolnix-gui - - name: Verify MKVToolNix installation + - name: Install MKVToolNix (macOS) + if: matrix.os == 'macos-latest' + run: brew install --quiet mkvtoolnix + - name: Install MKVToolNix (Windows) + if: matrix.os == 'windows-latest' + run: | + choco install -y --no-progress mkvtoolnix + echo "C:\Program Files\MKVToolNix" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Verify MKVToolNix installation (Windows) + if: matrix.os == 'windows-latest' + run: | + & "C:\Program Files\MKVToolNix\mkvmerge.exe" -V + shell: pwsh + - name: Verify MKVToolNix installation (Linux and macOS) + if: matrix.os != 'windows-latest' run: mkvmerge -V - - name: Set up Python + - name: Set up Python ${{ matrix.python-version }} id: setup-python uses: actions/setup-python@v5 with: - python-version: '3.11' + python-version: ${{ matrix.python-version }} - name: Install Poetry uses: snok/install-poetry@v1 with: - version: 1.8.3 + version: latest virtualenvs-create: true virtualenvs-in-project: true installer-parallel: true @@ -51,15 +71,18 @@ jobs: with: path: .venv key: venv-pypi-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + - name: Add Poetry to Path (Windows) + if: matrix.os == 'windows-latest' + run: | + echo "C:\Users\runneradmin\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Install dependencies if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' run: poetry install --no-interaction --no-root - name: Install project run: poetry install --no-interaction - name: Run tests and collect coverage - run: | - source .venv/bin/activate - make + run: poetry run make + shell: bash - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} diff --git a/pymkv/MKVTrack.py b/pymkv/MKVTrack.py index 4980f54..11fadc2 100644 --- a/pymkv/MKVTrack.py +++ b/pymkv/MKVTrack.py @@ -214,11 +214,11 @@ def file_path(self, file_path: str) -> None: Raises: ValueError: If the file is not a valid Matroska file or is not supported. """ - file_path = checking_file_path(file_path) - if not verify_supported(file_path, mkvmerge_path=self.mkvmerge_path): + fp = checking_file_path(file_path) + if not verify_supported(fp, mkvmerge_path=self.mkvmerge_path): msg = f"The file '{file_path}' is not a valid Matroska file or is not supported." raise ValueError(msg) - self._file_path = file_path + self._file_path = fp self.track_id = 0 @property diff --git a/pymkv/Verifications.py b/pymkv/Verifications.py index 7ff4ea6..506f5d1 100644 --- a/pymkv/Verifications.py +++ b/pymkv/Verifications.py @@ -238,12 +238,12 @@ def verify_supported( # noqa: ANN201 If the file cannot be opened or an error occurs during the verification process. """ mkvmerge_path = prepare_mkvtoolnix_path(mkvmerge_path) - file_path = verify_file_path_and_mkvmerge(file_path, mkvmerge_path) + fp = verify_file_path_and_mkvmerge(file_path, mkvmerge_path) try: if isinstance(mkvmerge_path, list): mkvmerge_path = tuple(mkvmerge_path) - info_json = get_file_info(file_path, mkvmerge_path, check_path=False) + info_json = get_file_info(fp, mkvmerge_path, check_path=False) except sp.CalledProcessError as e: - msg = '"{}" could not be opened' + msg = f'"{file_path}" could not be opened' raise ValueError(msg) from e return info_json["container"]["supported"] diff --git a/tests/test_bcp47.py b/tests/test_bcp47.py index 50a34c3..8f8333b 100644 --- a/tests/test_bcp47.py +++ b/tests/test_bcp47.py @@ -1,21 +1,28 @@ +import pytest + from pymkv import BCP47 def test_is_bcp47_en_US() -> None: # noqa: N802 - assert BCP47.is_bcp47("en-US") is True + assert _test_is_bcp47("en-US") is True def test_is_bcp47_fr_FR() -> None: # noqa: N802 - assert BCP47.is_bcp47("fr-FR") is True + assert _test_is_bcp47("fr-FR") is True def test_is_bcp47_english() -> None: - assert BCP47.is_bcp47("english") is False + assert _test_is_bcp47("english") is False def test_is_bcp47_und() -> None: - assert BCP47.is_bcp47("und") is True + assert _test_is_bcp47("und") is True def test_is_bcp47_empty() -> None: - assert BCP47.is_bcp47("") is False + assert _test_is_bcp47("") is False + + +def _test_is_bcp47(language_ietf: str) -> bool: + with pytest.deprecated_call(): + return BCP47.is_bcp47(language_ietf) diff --git a/tests/test_mkv_attachment.py b/tests/test_mkv_attachment.py index bbf5f10..7ad9fd1 100644 --- a/tests/test_mkv_attachment.py +++ b/tests/test_mkv_attachment.py @@ -71,6 +71,7 @@ def test_file_path_expansion(tmp_path: Path, monkeypatch) -> None: # noqa: ANN0 fake_home = tmp_path / "fake_home" fake_home.mkdir() monkeypatch.setenv("HOME", str(fake_home)) + monkeypatch.setenv("USERPROFILE", str(fake_home)) test_file = fake_home / "test_file.txt" test_file.write_text("Test content")