Closed
Conversation
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
|
7cf8d87 to
44121ed
Compare
415025a to
6dcc871
Compare
When finalizer() sets connections._db_config = None and another test runs on the same worker (with pytest-xdist), _reset_conn_state() would fail because it tried to call .clear() on None. This fix checks if _db_config is not None before clearing it. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
These tests use create_db which resets global state and interferes with other tests running in parallel. Added pytestmark to skip them when running with -n auto. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Only skip tests when running with xdist AND in-memory SQLite - Use TORTOISE_TEST_DB environment variable instead of hardcoded URLs - Skip file-based SQLite test when running non-SQLite databases - Tests now run normally in CI for postgres, mysql, etc. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Pull Request Test Coverage Report for Build 21523302371Details
💛 - Coveralls |
Member
Author
|
Resolved by #2069 |
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.
Fixes #1110
Now we restore default connections after clearing them
AI Summary:
This pull request introduces new tests and improvements to the database test initialization process, specifically targeting better support for pytest and pytest-asyncio workflows. The main focus is on fixing issues with database state management when using the
initializer()and adding a new asynccreate_db()helper for cleaner pytest fixture usage. Additionally, it adds comprehensive tests to ensure correct behavior across different database backends and usage patterns.Key changes:
Testing and CI Enhancements
test_pytest_initializer.pywith extensive tests for the new asynccreate_db()helper and improved pytest fixture patterns, ensuring isolation and correct DB state across tests.New Features and API Improvements
create_db()function intortoise.contrib.test, designed for use in pytest-asyncio fixtures, providing a more reliable and idiomatic way to set up test databases asynchronously. [1] [2]Bug Fixes and State Management
initializer()function to avoid clearing connections after initialization, fixing issues where the database became unusable until_restore_default()was called—this resolves problems with pytest fixtures expecting the DB to be ready immediately.finalizer()and test case teardown logic to ensure global state is properly reset after tests, preventing cross-test contamination. [1] [2]