[REFACTOR] refactor unit tests#479
Conversation
There was a problem hiding this comment.
Code Review
This pull request restructures the test suite by moving multi-GPU and other tests out of nested subdirectories to the root tests directory, updating relative imports and module paths accordingly. It also introduces a conftest.py file to ensure multi-GPU tests run before single-GPU tests to prevent CUDA context conflicts. The reviewer suggested optimizing the test collection modification logic in conftest.py to partition the tests in a single O(N) pass instead of performing redundant set allocations inside a list comprehension.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def pytest_collection_modifyitems(items: list) -> None: | ||
| multi_gpu = [i for i in items if any(p in _MULTI_GPU_DIRS for p in i.nodeid.split("/"))] | ||
| other = [i for i in items if i not in set(multi_gpu)] | ||
| items[:] = multi_gpu + other |
There was a problem hiding this comment.
In the current implementation, set(multi_gpu) is evaluated inside the list comprehension for every single item in items. This results in an
We can optimize this to a single items once and partitioning them into two lists directly.
| def pytest_collection_modifyitems(items: list) -> None: | |
| multi_gpu = [i for i in items if any(p in _MULTI_GPU_DIRS for p in i.nodeid.split("/"))] | |
| other = [i for i in items if i not in set(multi_gpu)] | |
| items[:] = multi_gpu + other | |
| def pytest_collection_modifyitems(items: list) -> None: | |
| multi_gpu = [] | |
| other = [] | |
| for item in items: | |
| if any(p in _MULTI_GPU_DIRS for p in item.nodeid.split("/")): | |
| multi_gpu.append(item) | |
| else: | |
| other.append(item) | |
| items[:] = multi_gpu + other |
No description provided.