Add root conftest.py to fix sonic_ax_impl import during pytest collection#371
Open
yxieca wants to merge 1 commit intosonic-net:masterfrom
Open
Add root conftest.py to fix sonic_ax_impl import during pytest collection#371yxieca wants to merge 1 commit intosonic-net:masterfrom
yxieca wants to merge 1 commit intosonic-net:masterfrom
Conversation
…tion On trixie (bookworm+) builds, the wheel build flow runs: pip install '.[testing]' → pip uninstall asyncsnmp → python -m pytest After pip uninstall, sonic_ax_impl is removed from site-packages. Individual test files add src/ to sys.path, but tests/mock_tables/dbconnector.py imports sonic_ax_impl.mibs at module level during pytest collection — before any test file's sys.path fixup runs. This causes ModuleNotFoundError on trixie where the asyncsnmp wheel cache misses and tests actually execute. Fix: add a root conftest.py that inserts src/ into sys.path before collection begins. This is a no-op when sonic_ax_impl is already installed. Signed-off-by: Ying Xie <ying.xie@microsoft.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
yxieca
added a commit
to yxieca/sonic-buildimage
that referenced
this pull request
Apr 11, 2026
Migrate docker-snmp from Debian bookworm to trixie base: - Update Dockerfile.j2 base image from bookworm to trixie - Install snmp/snmpd from Debian repos via apt-get (on trixie, snmpd is no longer built from source per sonic-net#26357) - Update rules/docker-snmp.mk references from BOOKWORM to TRIXIE - No bookworm guards needed for SNMP/SNMPD dependencies: those variables are only defined on bookworm (snmpd.mk), so they resolve to empty on trixie — depending on empty is harmless - Temporarily disable asyncsnmp unit tests (TEST=n) pending sonic-net/sonic-snmpagent#371 which fixes the sonic_ax_impl import error during pytest collection on trixie Signed-off-by: Ying Xie <ying.xie@microsoft.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On trixie (bookworm+) builds, the wheel build flow in sonic-buildimage runs:
After
pip uninstall,sonic_ax_implis removed from site-packages. Individual test files addsrc/tosys.path, buttests/mock_tables/dbconnector.pyimportssonic_ax_impl.mibsat module level during pytest collection — before any test file's path fixup runs. This causes:On bookworm the old
setup.py testflow didn't hit this because the package remained installed. On trixie, the build switched topip install/uninstall + pytest(slave.mk), and when the wheel cache misses, tests actually execute and fail.Fix
Add a root
conftest.pythat insertssrc/intosys.pathbefore pytest collection begins. This is harmless whensonic_ax_implis already installed.Motivation
Blocks sonic-net/sonic-buildimage#26551 (upgrade docker-snmp from bookworm to trixie).
Signed-off-by: Ying Xie ying.xie@microsoft.com