Skip to content

[Misc] Cleanup: use consistent pytest-mock in unit tests#2698

Merged
hsliuustc0106 merged 5 commits into
vllm-project:mainfrom
yuanheng-zhao:misc/use-cpu-pytest
Apr 13, 2026
Merged

[Misc] Cleanup: use consistent pytest-mock in unit tests#2698
hsliuustc0106 merged 5 commits into
vllm-project:mainfrom
yuanheng-zhao:misc/use-cpu-pytest

Conversation

@yuanheng-zhao
Copy link
Copy Markdown
Collaborator

@yuanheng-zhao yuanheng-zhao commented Apr 11, 2026

PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS (AT THE BOTTOM) HAVE BEEN CONSIDERED.

Purpose

This is a followup of already resolved #1291 . With more code merged developers still mixed together and used unittest.mock. We'd better write the recommended way to doc.

This PR made a cleanup to existing unit tests so that they apply consistent pytest-mock, while keeping test logics intact.

Test Plan

pytest -rs \
tests/comfyui/test_comfyui_integration.py \
tests/core/sched/test_generation_scheduler_restore.py \
tests/diffusion/distributed/test_distributed_vae_executor.py \
tests/diffusion/models/bagel/test_trajectory_recording.py \
tests/diffusion/models/flux2/test_flux2_transformer_tp.py \
tests/diffusion/offloader/test_sequential_backend.py \
tests/diffusion/quantization/test_int8_config.py \
tests/diffusion/test_diffusion_scheduler.py \
tests/diffusion/test_diffusion_step_pipeline.py \
tests/diffusion/test_diffusion_worker_cuda_profiler.py \
tests/diffusion/test_multiproc_engine_concurrency.py \
tests/engine/test_arg_utils.py \
tests/engine/test_async_omni_engine_input.py \
tests/engine/test_async_omni_engine_outputs.py \
tests/engine/test_single_stage_mode.py \
tests/entrypoints/openai_api/test_serving_chat_speaker.py \
tests/entrypoints/openai_api/test_serving_speech.py \
tests/entrypoints/openai_api/test_serving_speech_stream.py \
tests/entrypoints/test_omni_base_profiler.py \
tests/entrypoints/test_serve.py \
tests/model_executor/models/mimo_audio/test_mimo_audio_code2wav_batch_decode.py \
tests/model_executor/models/qwen2_5_omni/test_qwen2_5_omni_embed.py \
tests/model_executor/models/qwen3_tts/test_code_predictor_dtype.py \
tests/model_executor/models/test_fish_speech_voice_cache.py \
tests/test_fish_speech_voice_cache.py

Test Result

=========================================================================================== short test summary info ============================================================================================
SKIPPED [1] tests/diffusion/quantization/test_int8_config.py:263: NPU platform not available.
SKIPPED [1] tests/diffusion/quantization/test_int8_config.py:274: NPU platform not available.
SKIPPED [1] tests/diffusion/quantization/test_int8_config.py:283: NPU platform not available.
SKIPPED [1] tests/diffusion/quantization/test_int8_config.py:322: NPU platform not available.
SKIPPED [1] tests/diffusion/quantization/test_int8_config.py:334: NPU platform not available.
SKIPPED [1] tests/diffusion/quantization/test_int8_config.py:347: NPU platform not available.
=========================================================================== 401 passed, 6 skipped, 37 warnings in 128.54s (0:02:08)

Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan. Please provide the test scripts & test commands. Please state the reasons if your codes don't require additional test scripts. For test file guidelines, please check the test style doc
  • The test results. Please paste the results comparison before and after, or the e2e results.
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model. Please run mkdocs serve to sync the documentation editions to ./docs.
  • (Optional) Release notes update. If your change is user-facing, please update the release notes draft.

BEFORE SUBMITTING, PLEASE READ https://github.com/vllm-project/vllm-omni/blob/main/CONTRIBUTING.md (anything written below this line will be removed by GitHub Actions)

Copy link
Copy Markdown
Collaborator

@hsliuustc0106 hsliuustc0106 left a comment

Choose a reason for hiding this comment

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

Looks like a clean migration from unittest.mock to pytest-mock across the test suite. One thing to double-check:

conftest.py now uses ModuleType("comfy_api") stubs instead of MagicMock. If any test later accesses an attribute that doesn't exist on these stubs, it'll raise AttributeError instead of returning a mock — which is probably the intended behavior, but worth verifying the comfyui integration tests still pass with the exact attributes they touch.

@hsliuustc0106
Copy link
Copy Markdown
Collaborator

Test-only refactor, looks clean. Two notes:

  1. ModuleType stubs are stricter than MagicMock — if any downstream test relied on the looser mock behavior (e.g. accessing undefined attributes), those will start failing. Worth a quick grep for patterns like mock_xxx.any_attribute.
  2. Nice cleanup overall, gates pass.

@yuanheng-zhao
Copy link
Copy Markdown
Collaborator Author

There still exist other unittest.mock usage which I'll add and test tomorrow. And put updated and verified tests together into this PR

Signed-off-by: yuanheng <jonathan.zhaoyh@gmail.com>
Signed-off-by: yuanheng <jonathan.zhaoyh@gmail.com>
Signed-off-by: yuanheng <jonathan.zhaoyh@gmail.com>
Signed-off-by: yuanheng <jonathan.zhaoyh@gmail.com>
@yuanheng-zhao yuanheng-zhao marked this pull request as ready for review April 12, 2026 06:05
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@yuanheng-zhao
Copy link
Copy Markdown
Collaborator Author

I think we'd better add the preferred way of applying mock/patch (i.e., pytest MockerFixture, etc) in tests to a contributing doc, otherwise contributors and (*especially) AI coding assistant tend to import and apply outdated unittest usage into more incoming tests.

cc @congw729 , @yenuo26 , @tjtanaa

@yuanheng-zhao yuanheng-zhao changed the title [Misc] Restore unit tests to use pytest-mock [Misc] Cleanup: use consistent pytest-mock in unit tests Apr 12, 2026
@gcanlin gcanlin added the ready label to trigger buildkite CI label Apr 12, 2026
@hsliuustc0106 hsliuustc0106 merged commit e0cdbe9 into vllm-project:main Apr 13, 2026
8 checks passed
@yuanheng-zhao yuanheng-zhao deleted the misc/use-cpu-pytest branch April 13, 2026 12:04
Celeste-jq pushed a commit to IsleOfDawnlight/vllm-omni-voxcpm that referenced this pull request Apr 14, 2026
…t#2698)

Signed-off-by: yuanheng <jonathan.zhaoyh@gmail.com>
lengrongfu pushed a commit to lengrongfu/vllm-omni that referenced this pull request May 1, 2026
clodaghwalsh17 pushed a commit to clodaghwalsh17/nm-vllm-omni-ent that referenced this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready label to trigger buildkite CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Migrate to Use Consistent Unit Test Framework

3 participants