2026-03-21 17:51:36 +01:00
|
|
|
"""Tests for python_pkg.moviepy_showcase._moviepy_audio_output."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
|
|
from python_pkg.moviepy_showcase._moviepy_audio_output import (
|
|
|
|
|
_make_sine,
|
|
|
|
|
part4_audio,
|
|
|
|
|
part5_composition,
|
|
|
|
|
part6_drawing_tools,
|
|
|
|
|
part7_output,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ── _make_sine inner maker branches ──────────────────────────────
|
|
|
|
|
def test_make_sine_returns_clip() -> None:
|
|
|
|
|
clip = _make_sine(440.0, 2.0)
|
|
|
|
|
assert clip is not None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_make_sine_maker_scalar() -> None:
|
|
|
|
|
"""maker() with scalar t → t_arr.ndim == 0 → returns 1-D."""
|
|
|
|
|
import moviepy as mp
|
|
|
|
|
|
Reduce per-file-ignores by fixing lint violations across codebase
Fix ruff violations in ~15 source files and ~60+ test files to minimize
per-file-ignores in pyproject.toml. Remaining ignores are justified with
comments explaining why each suppression is necessary.
Source fixes: FBT003 (keyword args), S310 (URL validation), SLF001
(private access), T201 (print→logging), C901 (complexity), E501 (line
length), E402 (import order).
Test fixes: SIM117 (combined with), FBT (boolean args), PERF203 (try in
loop), S310/S607 (URLs/executables), E402/E501 (imports/lines), S108
(tmp paths), PLR0913 (too many args), ARG (unused args), ANN (type
annotations), RUF059 (unused unpacked vars), PT019 (fixture naming).
Remaining per-file-ignores (with justifications):
- Tests: ARG, D, PLC0415, PLR2004, S101, SLF001
- music_gen sources: PLC0415 (heavy ML lazy imports)
- moviepy_showcase: PLC0415 (circular dependency)
- generate_images: PLR0913 (matplotlib helpers need many params)
- praca_magisterska_video: E501, E402 (long paths, mpl.use)
2026-03-25 18:58:05 +01:00
|
|
|
mp.AudioClip.side_effect = lambda *_a, **_kw: MagicMock()
|
2026-03-21 17:51:36 +01:00
|
|
|
_make_sine(440.0, 1.0)
|
|
|
|
|
maker = mp.AudioClip.call_args[0][0]
|
|
|
|
|
|
|
|
|
|
result = maker(0.0)
|
|
|
|
|
assert isinstance(result, np.ndarray)
|
|
|
|
|
assert result.ndim == 1
|
|
|
|
|
assert result.shape == (2,)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_make_sine_maker_array() -> None:
|
|
|
|
|
"""maker() with array t → t_arr.ndim > 0 → returns 2-D."""
|
|
|
|
|
import moviepy as mp
|
|
|
|
|
|
Reduce per-file-ignores by fixing lint violations across codebase
Fix ruff violations in ~15 source files and ~60+ test files to minimize
per-file-ignores in pyproject.toml. Remaining ignores are justified with
comments explaining why each suppression is necessary.
Source fixes: FBT003 (keyword args), S310 (URL validation), SLF001
(private access), T201 (print→logging), C901 (complexity), E501 (line
length), E402 (import order).
Test fixes: SIM117 (combined with), FBT (boolean args), PERF203 (try in
loop), S310/S607 (URLs/executables), E402/E501 (imports/lines), S108
(tmp paths), PLR0913 (too many args), ARG (unused args), ANN (type
annotations), RUF059 (unused unpacked vars), PT019 (fixture naming).
Remaining per-file-ignores (with justifications):
- Tests: ARG, D, PLC0415, PLR2004, S101, SLF001
- music_gen sources: PLC0415 (heavy ML lazy imports)
- moviepy_showcase: PLC0415 (circular dependency)
- generate_images: PLR0913 (matplotlib helpers need many params)
- praca_magisterska_video: E501, E402 (long paths, mpl.use)
2026-03-25 18:58:05 +01:00
|
|
|
mp.AudioClip.side_effect = lambda *_a, **_kw: MagicMock()
|
2026-03-21 17:51:36 +01:00
|
|
|
_make_sine(440.0, 1.0)
|
|
|
|
|
maker = mp.AudioClip.call_args[0][0]
|
|
|
|
|
|
|
|
|
|
t = np.linspace(0, 1, 100)
|
|
|
|
|
result = maker(t)
|
|
|
|
|
assert isinstance(result, np.ndarray)
|
|
|
|
|
assert result.ndim == 2
|
|
|
|
|
assert result.shape == (100, 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ── part functions ───────────────────────────────────────────────
|
|
|
|
|
def test_part4_audio() -> None:
|
|
|
|
|
result = part4_audio()
|
|
|
|
|
assert isinstance(result, list)
|
|
|
|
|
assert len(result) > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_part5_composition() -> None:
|
|
|
|
|
result = part5_composition()
|
|
|
|
|
assert isinstance(result, list)
|
|
|
|
|
assert len(result) > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_part6_drawing_tools() -> None:
|
|
|
|
|
result = part6_drawing_tools()
|
|
|
|
|
assert isinstance(result, list)
|
|
|
|
|
assert len(result) > 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_part7_output() -> None:
|
|
|
|
|
result = part7_output()
|
|
|
|
|
assert isinstance(result, list)
|
|
|
|
|
assert len(result) > 0
|