Skip to content

chore: add targeted utils mutation tests#576

Draft
marandaneto wants to merge 2 commits into
mainfrom
chore/add-utils-mutation-tests
Draft

chore: add targeted utils mutation tests#576
marandaneto wants to merge 2 commits into
mainfrom
chore/add-utils-mutation-tests

Conversation

@marandaneto
Copy link
Copy Markdown
Member

@marandaneto marandaneto commented May 15, 2026

💡 Motivation and Context

Add targeted mutation testing coverage for posthog/utils.py so regressions in utility helpers and flag cache behavior are caught by tests.

This adds a focused mutmut configuration and CI job that only runs when the targeted mutation inputs change, with mutants/ cached across CI runs. The targeted utils tests now cover all statements in posthog/utils.py.

💚 How did you test it?

  • uv run --extra test pytest posthog/test/test_utils.py posthog/test/test_size_limited_dict.py --timeout=30 -q
  • uv run --extra test coverage run -m pytest posthog/test/test_utils.py posthog/test/test_size_limited_dict.py --timeout=30 -q && uv run --extra test coverage report -m posthog/utils.py
  • rm -rf mutants && uv run --extra test --with mutmut mutmut run --max-children 1 && uv run --extra test --with mutmut mutmut results
  • uv run --extra test pytest --timeout=30 -q
  • Parsed .github/workflows/ci.yml as YAML

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran sampo add to generate a changeset file

@marandaneto marandaneto requested a review from a team as a code owner May 15, 2026 22:42
@marandaneto marandaneto marked this pull request as draft May 15, 2026 22:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 16, 2026

posthog-python Compliance Report

Date: 2026-05-16 00:03:28 UTC
Duration: 4674437ms

⚠️ Some Tests Failed

29/45 tests passed, 16 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 518ms
Format Validation.Event Has Uuid 1507ms
Format Validation.Event Has Lib Properties 1507ms
Format Validation.Distinct Id Is String 1507ms
Format Validation.Token Is Present 1508ms
Format Validation.Custom Properties Preserved 1507ms
Format Validation.Event Has Timestamp 1507ms
Retry Behavior.Retries On 503 9519ms
Retry Behavior.Does Not Retry On 400 3506ms
Retry Behavior.Does Not Retry On 401 3507ms
Retry Behavior.Respects Retry After Header 9515ms
Retry Behavior.Implements Backoff 23518ms
Retry Behavior.Retries On 500 7517ms
Retry Behavior.Retries On 502 7512ms
Retry Behavior.Retries On 504 7513ms
Retry Behavior.Max Retries Respected 23528ms
Deduplication.Generates Unique Uuids 1499ms
Deduplication.Preserves Uuid On Retry 7515ms
Deduplication.Preserves Uuid And Timestamp On Retry 14519ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7512ms
Deduplication.No Duplicate Events In Batch 1504ms
Deduplication.Different Events Have Different Uuids 1508ms
Compression.Sends Gzip When Enabled 1508ms
Batch Format.Uses Proper Batch Structure 1507ms
Batch Format.Flush With No Events Sends Nothing 1006ms
Batch Format.Multiple Events Batched Together 1505ms
Error Handling.Does Not Retry On 403 3510ms
Error Handling.Does Not Retry On 413 3509ms
Error Handling.Retries On 408 7514ms

Feature_Flags Tests

⚠️ 0/16 tests passed, 16 failed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 506ms
Request Payload.Flags Request Uses V2 Query Param 300398ms
Request Payload.Flags Request Hits Flags Path Not Decide 301003ms
Request Payload.Flags Request Omits Authorization Header 300956ms
Request Payload.Token In Flags Body Matches Init 300992ms
Request Payload.Groups Round Trip 301007ms
Request Payload.Groups Default To Empty Object 301044ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 300998ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 300918ms
Request Payload.Disable Geoip Omitted Defaults To False 301081ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 301004ms
Request Lifecycle.No Flags Request On Init Alone 301000ms
Request Lifecycle.No Flags Request On Normal Capture 300994ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 300946ms
Request Lifecycle.Mock Response Value Is Returned To Caller 301059ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 300997ms

Failures

request_payload.request_with_person_properties_device_id

Field 'token' not found in /flags request body at path 'token'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'geoip_disable', 'device_id', 'flag_keys_to_evaluate', 'sentAt', 'api_key']

request_payload.flags_request_uses_v2_query_param

No error message

request_payload.flags_request_hits_flags_path_not_decide

No error message

request_payload.flags_request_omits_authorization_header

No error message

request_payload.token_in_flags_body_matches_init

No error message

request_payload.groups_round_trip

No error message

request_payload.groups_default_to_empty_object

No error message

request_payload.person_properties_distinct_id_auto_populated_when_caller_omits_it

No error message

request_payload.disable_geoip_false_propagates_as_geoip_disable_false

No error message

request_payload.disable_geoip_omitted_defaults_to_false

No error message

request_payload.flag_keys_to_evaluate_contains_only_requested_key

No error message

request_lifecycle.no_flags_request_on_init_alone

No error message

request_lifecycle.no_flags_request_on_normal_capture

No error message

request_lifecycle.two_flag_calls_produce_two_remote_requests

No error message

request_lifecycle.mock_response_value_is_returned_to_caller

No error message

side_effect_events.get_feature_flag_captures_feature_flag_called_event

No error message

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