Repository navigation
tests: fix flaky JWT and config-migration unit tests - #1243
Merged
Merged
Conversation
JWT tests built the expected token in a second call to _get_jwt_payload(), so a second boundary between the two calls changed iat/exp/nbf. Freeze time. The config-migration fixtures patched builtins.open and builtins.print, so any other code opening a file during the test (ddtrace writing .pyc caches) broke assert_called_once_with. Patch them only in the module under test.
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. 💡 Show Tips and TricksTesting This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@tolik0/fix-flaky-unit-tests#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch tolik0/fix-flaky-unit-testsPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
Patrick Nilan (pnilan)
approved these changes
Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes two unit-test flakes that fail unrelated PRs (for example #1232):
unit_tests/sources/declarative/auth/test_jwt.py):test_get_signed_token,test_get_request_optionsandtest_get_request_headersnow run underfreezegun.freeze_time, astest_get_jwt_payloadalready does.migration_mocksintest_manifest_declarative_source.pyandtest_concurrent_declarative_source.py):openandprintare now patched only in the module under test, not inbuiltins.Why
_get_jwt_payload(). When a second boundary falls between that call and the authenticator's own call,iat,nbfandexpdiffer and the tokens don't match. This failedtest_get_request_options[test_get_request_headers1]on Python 3.11 andtest_get_signed_tokenon Python 3.12 in the same run.builtins.opencatches everyopencall in the process during the test. In CI, ddtrace read/proc/self/cgroupand wrote a.pyccache file through the mock, soassert_called_once_with("/fake/config/path", "w")failed withExpected 'open' to be called once. Called 6 times.Verification
poetry run pytest unit_tests/sources/declarative/auth/test_jwt.py unit_tests/legacy/sources/declarative/test_manifest_declarative_source.py unit_tests/sources/declarative/test_concurrent_declarative_source.py -k "jwt or Jwt or migrat": 27 passed.ruff formatandruff checkare clean.🤖 Generated with Claude Code