Skip to content

Commit

Permalink
Run pytest suite on built wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange committed May 6, 2024
1 parent ca4def3 commit 84667ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions test/python_magic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 84667ee

Please # to comment.