commit:     477b55fa7d4a615d70fccb8eb857817e089f7d75
Author:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 23 10:51:59 2025 +0000
Commit:     Ionen Wolkens <ionen <AT> gentoo <DOT> org>
CommitDate: Thu Oct 23 10:56:10 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=477b55fa

dev-python/yt-dlp-ejs: add basic tests and tidy

Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>

 .../yt-dlp-ejs/files/yt-dlp-ejs-0.1.0-tests.patch  | 27 ++++++++++++++++++++++
 dev-python/yt-dlp-ejs/yt-dlp-ejs-0.1.0.ebuild      | 16 ++++++++-----
 2 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/dev-python/yt-dlp-ejs/files/yt-dlp-ejs-0.1.0-tests.patch 
b/dev-python/yt-dlp-ejs/files/yt-dlp-ejs-0.1.0-tests.patch
new file mode 100644
index 000000000000..96875159f08c
--- /dev/null
+++ b/dev-python/yt-dlp-ejs/files/yt-dlp-ejs-0.1.0-tests.patch
@@ -0,0 +1,27 @@
+Very basic tests but adding early to ensure ebuild is sorted out
+before this starts getting used in full.
+https://github.com/yt-dlp/ejs/pull/17
+--- a/test/__init__.py
++++ b/test/__init__.py
+@@ -0,0 +1 @@
++
+--- a/test/test_modules.py
++++ b/test/test_modules.py
+@@ -0,0 +1,17 @@
++import unittest
++from pathlib import Path
++
++import yt_dlp_ejs.yt.solver
++
++CORE_PATH = Path('yt_dlp_ejs/yt/solver/core.min.js')
++LIB_PATH = Path('yt_dlp_ejs/yt/solver/lib.min.js')
++
++
++class TestModules(unittest.TestCase):
++    def test_yt_solver(self):
++        self.assertEqual(yt_dlp_ejs.yt.solver.core(), 
CORE_PATH.read_text(encoding='utf-8'))
++        self.assertEqual(yt_dlp_ejs.yt.solver.lib(), 
LIB_PATH.read_text(encoding='utf-8'))
++
++
++if __name__ == '__main__':
++    unittest.main()

diff --git a/dev-python/yt-dlp-ejs/yt-dlp-ejs-0.1.0.ebuild 
b/dev-python/yt-dlp-ejs/yt-dlp-ejs-0.1.0.ebuild
index fe8383a5435a..cd64dd650f91 100644
--- a/dev-python/yt-dlp-ejs/yt-dlp-ejs-0.1.0.ebuild
+++ b/dev-python/yt-dlp-ejs/yt-dlp-ejs-0.1.0.ebuild
@@ -12,24 +12,28 @@ HOMEPAGE="https://github.com/yt-dlp/ejs/";
 SRC_URI+=" $(pypi_wheel_url --unpack)"
 
 LICENSE="Unlicense"
-LICENSE+=" ISC MIT" # .js dependencies
+LICENSE+=" ISC MIT" # .js dependencies from the wheel
 SLOT="0"
-# in-sync with yt-dlp and always straight-to-stable like yt-dlp itself
+# bumps should typically be done straight-to-stable like yt-dlp itself
 KEYWORDS="amd64 arm arm64 ~hppa ppc ppc64 ~riscv x86 ~arm64-macos ~x64-macos"
-# tests do not use python and are troublesome due to javascript, if in
-# doubt try downloading a youtube video with yt-dlp as a basic test
-RESTRICT="test"
 
 BDEPEND="
        app-arch/unzip
        dev-python/hatch-vcs[${PYTHON_USEDEP}]
 "
 
+# this only tests basic python bits without javascript to avoid headaches
+distutils_enable_tests unittest
+
+PATCHES=(
+       "${FILESDIR}"/${P}-tests.patch
+)
+
 src_prepare() {
        distutils-r1_src_prepare
 
        # drop deno/npm calls and use the pre-generated .js from the .whl
-       # instead, this both prevent network use and ensures no hash
+       # instead, this both prevents network use and ensures no hash
        # mismatch given yt-dlp checks the sha512sum of the .js files
        # (makes generating our own meaningless given can't be patched)
        sed -i '/wheel.hooks.custom/d' pyproject.toml || die

Reply via email to