diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78f5076..20813f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -96,8 +96,11 @@ jobs: CIBW_BEFORE_BUILD: ${{ ( startsWith( matrix.os, 'macos' ) && 'sudo -E bash add_libmagic.sh' ) || 'bash add_libmagic.sh' }} # build macos wheels with maximum backwards compatibility (gcc -mmacosx-version-min flag) MACOSX_DEPLOYMENT_TARGET: ${{ ( endsWith( matrix.only, 'arm64' ) && '11.0' ) || '10.9' }} - # simple smoke test run on each wheel: this is an HLS MP4 video, only recognised in recent versions of libmagic - CIBW_TEST_COMMAND: python -c "import magic; assert magic.Magic(mime=True).from_buffer(b'\x00\x00\x00\x1cftypiso5\x00\x00\x00\x01isomiso5hlsf\x00\x00') == 'video/mp4'" + # run pytest on each wheel (after cibuildwheel installs it outside the build venv) + CIBW_TEST_REQUIRES: pytest + CIBW_TEST_COMMAND: pytest {project} + # for pytest on windows + LC_ALL: en_US.UTF-8 - uses: actions/upload-artifact@v4 with: diff --git a/test/python_magic_test.py b/test/python_magic_test.py index 7ead8dd..859aa02 100755 --- a/test/python_magic_test.py +++ b/test/python_magic_test.py @@ -88,6 +88,12 @@ def test_from_buffer_str_and_bytes(self): in ("text/x-python", "text/x-script.python") ) + def test_recent_libmagic_version(self): + m = magic.Magic(mime=True) + # this type of (hls) mp4 file is only recognized in recent libmagic versions + hls_bytes = b"\x00\x00\x00\x1cftypiso5\x00\x00\x00\x01isomiso5hlsf\x00\x00" + self.assertEqual(m.from_buffer(hls_bytes), "video/mp4") + def test_mime_types(self): dest = os.path.join(MagicTest.TESTDATA_DIR, b"\xce\xbb".decode("utf-8")) shutil.copyfile(os.path.join(MagicTest.TESTDATA_DIR, "lambda"), dest)