Skip to content
This repository was archived by the owner on Jun 8, 2026. It is now read-only.

test: unit test case fix#1057

Merged
harshachinta merged 3 commits into
googleapis:mainfrom
surbhigarg92:main
Jan 7, 2024
Merged

test: unit test case fix#1057
harshachinta merged 3 commits into
googleapis:mainfrom
surbhigarg92:main

Conversation

@surbhigarg92

@surbhigarg92 surbhigarg92 commented Dec 15, 2023

Copy link
Copy Markdown
Contributor

Problem: Unit tests in test_spanner.py were behaving unexpectedly. For ex, when unit test test_transaction_should_use_transaction_id_returned_by_first_readwas run on local as single test it fails with below error

FAILED tests/unit/test_spanner.py::TestTransaction::test_transaction_should_use_transaction_id_returned_by_first_read - AssertionError: expected call not found.

but when it is run combined with other tests it succeeds. The above error showed that the difference was in transaction_tag that gets passed through request_options.

Reason: Python does not enforce immutability, leading to an unexpected situation where an object, assigned as REQUEST_OPTIONS = RequestOptions(), was anticipated to behave as a constant across all test cases.

However, it was found that this object was being modified, causing inconsistencies in the test cases. Varied behaviors were observed when executing a single test case compared to running the entire file.

@surbhigarg92
surbhigarg92 requested review from a team December 15, 2023 07:57
@product-auto-label product-auto-label Bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/python-spanner API. labels Dec 15, 2023
@surbhigarg92 surbhigarg92 changed the title chore: unit test case fix test: unit test case fix Dec 15, 2023
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Jan 7, 2024
@harshachinta
harshachinta merged commit 07a0202 into googleapis:main Jan 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/python-spanner API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants