Skip to content

Commit bdc9067

Browse files
committed
added a test for multiple os
1 parent 89d8cc7 commit bdc9067

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

.github/workflows/create-index.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build & Deploy pip Simple Index
1+
name: Create Simple pip Index
22

33
on:
44
release:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Test mediapipe-numpy2
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
test:
13+
name: Test on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os:
19+
- ubuntu-latest
20+
- windows-latest
21+
- macos-latest
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
27+
- name: Set up Python 3.12
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: '3.12'
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install numpy>2
36+
pip install mediapipe_numpy2 --extra-index-url https://cansik.github.io/mediapipe-numpy2/
37+
38+
- name: Run unit tests
39+
run: |
40+
python -m unittest discover -v tests

tests/test_pose_estimator.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import unittest
2+
3+
import mediapipe as mp
4+
import numpy as np
5+
6+
7+
class TestPoseEstimator(unittest.TestCase):
8+
def test_pose_estimator_on_zero_image(self):
9+
# create a blank RGB image
10+
image = np.zeros((480, 640, 3), dtype=np.uint8)
11+
12+
mp_pose = mp.solutions.pose
13+
with mp_pose.Pose(static_image_mode=True) as pose:
14+
results = pose.process(image)
15+
16+
# We got a results object
17+
self.assertIsNotNone(results)
18+
19+
# It should have a pose_landmarks attribute
20+
self.assertTrue(hasattr(results, "pose_landmarks"))
21+
22+
# If landmarks were detected, they should be a numpy array
23+
if results.pose_landmarks is not None:
24+
self.assertIsInstance(results.pose_landmarks, np.ndarray)
25+
# 33 keypoints × (x, y, z)
26+
self.assertEqual(results.pose_landmarks.ndim, 2)
27+
self.assertEqual(results.pose_landmarks.shape[1], 3)
28+
29+
30+
if __name__ == "__main__":
31+
unittest.main()

0 commit comments

Comments
 (0)