-
Notifications
You must be signed in to change notification settings - Fork 50
test: unittest to pytest #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Voyz
wants to merge
30
commits into
master
Choose a base branch
from
unittest-to-pytest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
This change creates a detailed migration plan to convert all existing unittest-based tests to pytest. The plan is structured into chunks to allow for parallel work by multiple AI agents. The plan is located in `test/migration_plan.md` and includes: - A method for identifying all unittest files. - General guidelines for the migration. - A file-by-file breakdown with specific migration steps and potential challenges.
This change creates a detailed migration plan to convert all existing unittest-based tests to pytest. The plan is structured into chunks to allow for parallel work. The plan is located in `test/migration_plan.md` and includes: - A method for identifying all unittest files. - General guidelines for the migration. - A file-by-file breakdown with specific migration steps and potential challenges.
This change creates a comprehensive, file-by-file migration plan to convert all existing unittest-based tests to pytest. The plan is structured into individually actionable chunks. The plan is located in `test/migration_plan.md` and includes: - General guidelines for the migration. - A detailed analysis of each unittest file. - Specific migration steps and potential challenges for each file.
Adds a new pytest-friendly test utility file at `test/test_utils_new.py`. This file includes the `capture_logs` context manager and decorator for advanced log testing. Creates a detailed migration plan in `test/migration_plan.md` to guide the conversion of all existing unittest files to pytest. The plan instructs developers to create new test files for side-by-side comparison and to use the new utilities.
Adds a new pytest-friendly test utility file at `test/test_utils_new.py`. This file includes the `capture_logs` context manager and decorator for advanced log testing. Creates a detailed migration plan in `test/migration_plan.md` to guide the conversion of all existing unittest files to pytest. The plan instructs developers to create new test files for side-by-side comparison and to use the new utilities.
Adds a new pytest-friendly test utility file at `test/test_utils_new.py`. This file includes the `capture_logs` context manager and decorator for advanced log testing. Creates a detailed migration plan in `test/migration_plan.md` to guide the conversion of all existing unittest files to pytest. The plan instructs developers to create new test files for side-by-side comparison and to use the new utilities.
Adds a new pytest-friendly test utility file at `test/test_utils_new.py`. This file includes the `capture_logs` context manager and decorator for advanced log testing, along with other test helpers. Creates a detailed migration plan in `test/migration_plan.md` to guide the conversion of all existing unittest files to pytest. The plan instructs developers to create new test files for side-by-side comparison and to use the new utilities.
Adds a new pytest-friendly test utility file at `test/test_utils_new.py`. This file includes the `capture_logs` context manager and decorator for advanced log testing, along with other test helpers. Moves the `get_logger_children` function from the test utilities to `ibind/support/logs.py` to make it a general-purpose utility. Creates a detailed migration plan in `test/migration_plan.md` to guide the conversion of all existing unittest files to pytest. The plan instructs developers to create new test files for side-by-side comparison and to use the new utilities.
Feat: Create unittest to pytest migration plan
Migrated the unittest-based tests in test/integration/base/test_rest_client_i.py to pytest-style tests in a new file, test/integration/base/test_rest_client_i_new.py. This migration includes: - Converting unittest.TestCase to pytest test functions. - Replacing setUp with pytest fixtures. - Replacing unittest assertions with pytest assertions. - Using the mocker fixture for patching. - Using the CaptureLogsContext for logging assertions. Also includes a defensive fix to test/test_utils_new.py to handle a TypeError when calling the make_clean_stack function.
Migrated the unittest-based tests in test/integration/base/test_rest_client_i.py to pytest-style tests in a new file, test/integration/base/test_rest_client_i_new.py. This migration includes: - Converting unittest.TestCase to pytest test functions. - Replacing setUp with pytest fixtures. - Replacing unittest assertions with pytest assertions. - Using the mocker fixture for patching. - Using the CaptureLogsContext for logging assertions. Added ## Arrange, ## Act, and ## Assert comments to all tests in the new file to improve readability. Split the `test_default_rest` function into three separate tests for better test isolation. Includes a defensive fix to test/test_utils_new.py to handle a TypeError when calling the make_clean_stack function.
Migrated the unittest-based tests in test/integration/base/test_rest_client_i.py to pytest-style tests in a new file, test/integration/base/test_rest_client_i_new.py. This migration includes: - Converting unittest.TestCase to pytest test functions. - Replacing setUp with pytest fixtures. - Replacing unittest assertions with pytest assertions. - Using the mocker fixture for patching. - Using the CaptureLogsContext for logging assertions. Improved test readability by: - Adding ## Arrange, ## Act, and ## Assert comments to all tests. - Splitting the `test_default_rest` function into three separate tests for better test isolation. Also includes a defensive fix to test/test_utils_new.py to handle a TypeError when calling the make_clean_stack function.
Split tuple fixtures into constants + granular fixtures; add autouse requests_mock with default return_value to reduce boilerplate in migrated tests.
…cting the inner strings outside of f-string
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.
This PR converts all remaining unittest tests into pytest.
One test file was already in pytest -
unit/client/test_ibkr_client_uand was not touched during this refactor.The migration has been carried out by AI agents - Google Jules and ChatGPT 5.2 through Windsurf. I then then manually reviewed each test, compared against the original, checked coverage and its intended functionality, and adjusted where needed.
Substantial simplifications were introduced to websocket tests, removing the _run_in_context functions and effectively flattening the resulting tests.
Also, the
SafeAssertLogsandRaiseLogsContextin thetest_utilswere replaced by thecapture_logsdecorator.@weklund - tagging you here in case you'd like to give this PR a review, though no worries if you're busy.
There is a tiny discrepancy between the resulting coverage since the pytest broke out some tests and effectively increased coverage.
Unittest coverage:
Pytest coverage: