dify - ✅(Solved) Fix test_baidu_obs.py fails to collect: 'fixture setup_baidu_obs_mock not found' [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langgenius/dify#35623Fetched 2026-04-29 06:36:28
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
1
Author
Participants
Timeline (top)
closed ×1cross-referenced ×1labeled ×1

Error Message

ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_save - fixture 'setup_baidu_obs_mock' not found ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_load_once - fixture 'setup_baidu_obs_mock' not found ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_load_stream - fixture 'setup_baidu_obs_mock' not found ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_download - fixture 'setup_baidu_obs_mock' not found ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_exists - fixture 'setup_baidu_obs_mock' not found ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_delete - fixture 'setup_baidu_obs_mock' not found

Root Cause

Root cause: test_baidu_obs.py does

Fix Action

Fixed

PR fix notes

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

Description (problem / solution / changelog)

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

BeforeAfter
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.

Changed files

  • api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py (modified, +2/-1)

Code Example

cd api
   MOCK_SWITCH=true pytest tests/unit_tests/oss/baidu_obs/test_baidu_obs.py

---

ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_save - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_load_once - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_load_stream - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_download - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_exists - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_delete - fixture 'setup_baidu_obs_mock' not found

---

from tests.unit_tests.oss.__mock.baidu_obs import setup_baidu_obs_mock
RAW_BUFFERClick to expand / collapse

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

N/A — CI failure on main (HEAD 2d6babeeb4). The bug is in repo test code, not in a deployed instance.

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

  1. Check out main (or any branch that contains #34330).

  2. Run the unit-test job locally:

    cd api
    MOCK_SWITCH=true pytest tests/unit_tests/oss/baidu_obs/test_baidu_obs.py
  3. Or open any PR that touches paths matched by the API path filter on Run API Tests / API Unit Tests (3.12) — e.g. https://github.com/langgenius/dify/pull/35515 — and observe the unit-test job fail.

✔️ Expected Behavior

tests/unit_tests/oss/baidu_obs/test_baidu_obs.py collects and runs to completion, the same way test_aliyun_oss.py, test_tencent_cos.py and test_volcengine_tos.py do.

❌ Actual Behavior

Six setup ERRORs, one per test in TestBaiduObs:

ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_save - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_load_once - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_load_stream - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_download - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_exists - fixture 'setup_baidu_obs_mock' not found
ERROR api/tests/unit_tests/oss/baidu_obs/test_baidu_obs.py::TestBaiduObs::test_delete - fixture 'setup_baidu_obs_mock' not found

Root cause: test_baidu_obs.py does

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

which imports the function but does not register it as a pytest fixture. Sister files (test_aliyun_oss.py, test_tencent_cos.py, test_volcengine_tos.py) instead use pytest_plugins = ("tests.unit_tests.oss.__mock.<provider>",), which is the supported registration mechanism. test_baidu_obs.py is missing that line.

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 hit the failure.

Fix proposed in PR #35618.

extent analysis

TL;DR

The most likely fix is to register the setup_baidu_obs_mock function as a pytest fixture by adding the pytest_plugins line in test_baidu_obs.py.

Guidance

  • Verify that the pytest_plugins line is missing in test_baidu_obs.py by comparing it with sister files (test_aliyun_oss.py, test_tencent_cos.py, test_volcengine_tos.py).
  • Add the pytest_plugins line to test_baidu_obs.py to register the setup_baidu_obs_mock function as a pytest fixture.
  • Run the unit-test job locally to confirm that the fix resolves the errors.
  • Review PR #35618 to ensure the proposed fix is correct and complete.

Example

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

Notes

The issue is specific to the test_baidu_obs.py file and the missing pytest_plugins line. The fix should be applied to this file only.

Recommendation

Apply the workaround by adding the pytest_plugins line to test_baidu_obs.py, as this is the most direct and targeted solution to the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING