Skip TensorFlow-backed tests cleanly when the tf extra is absent - #3419
Open
natsukium wants to merge 1 commit into
Open
Skip TensorFlow-backed tests cleanly when the tf extra is absent#3419natsukium wants to merge 1 commit into
natsukium wants to merge 1 commit into
Conversation
These test modules call pytest.importorskip("tensorflow") only after
importing tensorflow-backed code (deeplabcut.pose_estimation_tensorflow).
Since a failing import aborts module loading, the guard was never reached.
Move importorskip above those imports so the modules skip cleanly, and add
the missing guard to test_predict_supermodel, which had none. This lets the
test suite be collected and run in a base install.
deruyter92
approved these changes
Jul 22, 2026
deruyter92
left a comment
Collaborator
There was a problem hiding this comment.
Good PR, correct fix. LGTM!
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.
While working on #3417, I noticed that the test suite could no longer be collected in a base install (without the
tfextra).pytest.importorskip("tensorflow")is meant to skip these tests when TensorFlow is not installed. However, in the affected modules the guard is placed after the imports of TF-backed code fromdeeplabcut.pose_estimation_tensorflow. During pytest's collection phase those imports run first, so a base install raises an import error before the guard is ever reached, making theimportorskipeffectively a no-op.This PR does three things. It moves
pytest.importorskip("tensorflow")above the TF-backed imports in the affected modules so they skip cleanly instead of erroring, it adds the missing guard totest_predict_supermodel.pywhich had none, and it marks the relocated imports with# noqa: E402since they now intentionally follow module-level code.