Skip to content

Add regression test for UUID values (#24) - #172

Open
GiannopoulosK wants to merge 1 commit into
django-commons:mainfrom
GiannopoulosK:test-uuid-values-issue-24
Open

GiannopoulosK wants to merge 1 commit into
django-commons:mainfrom
GiannopoulosK:test-uuid-values-issue-24

Conversation

@GiannopoulosK

Copy link
Copy Markdown

Closes #24.

Summary

The ValueError: Cannot convert UUID(...) to Excel reported in #24 no longer occurs. It was fixed indirectly by #34 (released in 0.4.1), which runs cell values through str() as part of value sanitization. Before that change, raw uuid.UUID objects were passed straight to openpyxl, which can't write them.

I confirmed the export works on the latest release (2.6.0).

Changes

Since nothing in the code handles UUIDs explicitly, this adds a regression test (test_uuid_values) so the bug can't silently return if the sanitization logic changes. It covers:

  • UUIDField (DRF already serializes this to a string)
  • ReadOnlyField passing a raw uuid.UUID through
  • SerializerMethodField returning a raw uuid.UUID

The test first asserts that the last two really do produce uuid.UUID objects, then checks that all three cells contain the UUID as a string.

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

ValueError: Cannot convert UUID('some_uuid') to Excel

1 participant