Skip to content

Add unit tests and a GitHub Actions workflow to run them - #30

Open
ivnpsvc wants to merge 1 commit into
microsoft:mainfrom
ivnpsvc:add-basic-tests
Open

ivnpsvc wants to merge 1 commit into
microsoft:mainfrom
ivnpsvc:add-basic-tests

Conversation

@ivnpsvc

@ivnpsvc ivnpsvc commented Oct 8, 2026

Copy link
Copy Markdown

Following up on #28 and the discussion with Zhongqi on Discord, this adds a first set of tests and a workflow that runs them on pull requests and on pushes to main.

What's included

  • tests/: 33 unit tests that run in a few seconds and don't download any model weights (they also pass offline). They use small generated images and hand-built detection results:
    • the package and its main modules can be imported
    • MegaDetectorV6: an unknown version raises a clear error, the default version is valid, class names
    • utils.post_process: detection JSON (contents, excluded categories, relative paths), Timelapse JSON ([x, y, width, height] boxes, categories, max_detection_conf), sorting into Animal/ and No_animal/ (including the threshold), crops (names and sizes), annotated images, and keeping camera subfolders with input_dir
    • data: image file extensions, letterbox (size, aspect ratio, padding) and the transforms
  • .github/workflows/tests.yml: runs the tests on Python 3.10 and 3.12, with the actions pinned to the same commit SHAs as publish.yml.

Note on dependencies

The workflow installs soundfile, librosa and setuptools<82 explicitly, because import PytorchWildlife fails without them (#26). I left pyproject.toml unchanged so that fix can be handled in #26; once it's merged, these can be removed from the workflow.

Running locally

pip install -e . pytest soundfile librosa "setuptools<82"
pytest

@ivnpsvc

ivnpsvc commented Oct 8, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant