Skip to content

[REFACTOR] refactor unit tests#479

Merged
mayank31398 merged 6 commits into
mainfrom
cl
Jun 24, 2026
Merged

[REFACTOR] refactor unit tests#479
mayank31398 merged 6 commits into
mainfrom
cl

Conversation

@mayank31398

Copy link
Copy Markdown
Collaborator

No description provided.

Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>
Signed-off-by: Mayank Mishra <mayank31398@gmail.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/conftest.py
Comment on lines +14 to +17
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the current implementation, set(multi_gpu) is evaluated inside the list comprehension for every single item in items. This results in an $O(N^2)$ complexity and redundant set allocations.

We can optimize this to a single $O(N)$ pass by iterating through items once and partitioning them into two lists directly.

Suggested change
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

@mayank31398 mayank31398 merged commit 423d3ba into main Jun 24, 2026
2 checks passed
@mayank31398 mayank31398 deleted the cl branch June 24, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant