Skip to content

test: add unit tests for image_array_to_data_uri#5657

Open
eeshsaxena wants to merge 1 commit into
plotly:mainfrom
eeshsaxena:test/data-utils
Open

test: add unit tests for image_array_to_data_uri#5657
eeshsaxena wants to merge 1 commit into
plotly:mainfrom
eeshsaxena:test/data-utils

Conversation

@eeshsaxena

Copy link
Copy Markdown

Description

_plotly_utils.data_utils.image_array_to_data_uri converts a numpy uint8
image array into a base64 PNG/JPG data URI. It had no direct test coverage.

This adds tests/test_optional/test_utils/test_data_utils.py covering:

  • greyscale (2D), RGB and RGBA arrays each producing a PNG data URI
  • ValueError on out-of-range compression (-1 and 10)
  • ValueError on an invalid image shape
  • ValueError when requesting jpg with a non-PIL backend

The tests use the pypng backend so they do not require Pillow. No source
changes.

Verification

pytest tests/test_optional/test_utils/test_data_utils.py - 7 passed.
ruff check / ruff format --check clean.

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