Skip to content
Merged
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
41 changes: 32 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,51 @@ 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
sudo wget -O /usr/share/keyrings/gpg-pub-moritzbunkus.gpg https://mkvtoolnix.download/gpg-pub-moritzbunkus.gpg
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
Expand All @@ -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' }}
Expand Down
6 changes: 3 additions & 3 deletions pymkv/MKVTrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pymkv/Verifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@
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'

Check warning on line 247 in pymkv/Verifications.py

View check run for this annotation

Codecov / codecov/patch

pymkv/Verifications.py#L247

Added line #L247 was not covered by tests
raise ValueError(msg) from e
return info_json["container"]["supported"]
17 changes: 12 additions & 5 deletions tests/test_bcp47.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions tests/test_mkv_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading