Skip to content

fix(test): register baidu_obs mock as pytest plugin#35618

Merged
crazywoola merged 1 commit intolanggenius:mainfrom
lin-snow:fix/baidu-obs-pytest-plugins
Apr 28, 2026
Merged

fix(test): register baidu_obs mock as pytest plugin#35618
crazywoola merged 1 commit intolanggenius:mainfrom
lin-snow:fix/baidu-obs-pytest-plugins

Conversation

@lin-snow
Copy link
Copy Markdown
Contributor

@lin-snow lin-snow commented Apr 28, 2026

Fixes #35623

Summary

api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py (added in #34330) imports the mock fixture as a regular module-level symbol:

from tests.unit_tests.oss.__mock.baidu_obs import setup_baidu_obs_mock

That imports the function but does not register it as a pytest fixture, so any run that actually collects this file fails with fixture 'setup_baidu_obs_mock' not found and 6 ERROR entries (one per test in TestBaiduObs).

This PR replaces the unused import with the standard pytest_plugins declaration, matching test_aliyun_oss.py, test_tencent_cos.py and test_volcengine_tos.py:

pytest_plugins = ("tests.unit_tests.oss.__mock.baidu_obs",)

Why this slipped through CI: Run API Tests / API Unit Tests (3.12) is gated by a path filter. PR #34330 only touched files under api/tests/unit_tests/oss/baidu_obs/, which the filter does not recognize as an "API change", so the unit-test job was skipped on that PR and on every subsequent main push. The first PRs that touch broader api/ paths (e.g. #35515) hit the failure. Verified by inspecting the job conclusions on recent main runs: Run API Tests is skipped on every one of them.

Verification:

$ MOCK_SWITCH=true pytest tests/unit_tests/oss/baidu_obs/test_baidu_obs.py
======================== 7 passed, 2 warnings in 0.46s =========================

Screenshots

Before After
ERROR ... fixture 'setup_baidu_obs_mock' not found (×6) 7 passed

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

Note on make type-check: the command surfaces several pre-existing errors on main (e.g. app_factory.py:132, services/model_load_balancing_service.py:623, several in providers/trace/trace-tencent/...) that are unrelated to this one-line test fix. Confirmed identical errors on upstream/main HEAD.

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 28, 2026
@lin-snow lin-snow self-assigned this Apr 28, 2026
`from tests.unit_tests.oss.__mock.baidu_obs import setup_baidu_obs_mock`
imports the function but does not register it as a pytest fixture, so
`TestBaiduObs.setup_method(self, setup_baidu_obs_mock)` raises
`fixture 'setup_baidu_obs_mock' not found` whenever the unit-test job
actually runs this file.

Replace the unused import with `pytest_plugins = (...)`, matching the
pattern already used by `test_aliyun_oss.py`, `test_tencent_cos.py`, and
`test_volcengine_tos.py`.

The bug slipped through CI on langgenius#34330 because the path filter on
`Run API Tests / API Unit Tests` skips any PR that only touches
`api/tests/unit_tests/oss/baidu_obs/`, so the fixture was never resolved
in main's CI runs.
@lin-snow lin-snow force-pushed the fix/baidu-obs-pytest-plugins branch from 6561ed2 to a54a053 Compare April 28, 2026 03:48
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 28, 2026
@crazywoola crazywoola added this pull request to the merge queue Apr 28, 2026
Merged via the queue into langgenius:main with commit 0c280ef Apr 28, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_baidu_obs.py fails to collect: 'fixture setup_baidu_obs_mock not found'

2 participants