-
Notifications
You must be signed in to change notification settings - Fork 54
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
Conversation
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
|
@Voyz interesting! I'm back online starting tomorrow so would love to take a look :) |
|
Great use of fixtures! Overall great PR, just a small nit I see on imports. I see use inconsistent import patterns: Pattern 1 (with test. prefix):
Pattern 2 (without test. prefix):
|
|
Well spotted @weklund 🙌 - I've made them uniform (importing from |
|
LGTM. Not seeing 'approve' button for some reason. @Voyz |
|
Thanks, merging 🚀 |
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: