Revise tests that rely on importlib.reload #1205
Labels
contrib
Targeting pyhf.contrib and not the core of pyhf
follow up
help wanted
Extra attention is needed / contributions welcome
tests
pytest
Description
RE:
pyhf
related Stack Overflow question "How to remove a library with monkeypatch or mock in pytest?" which was used to write tests for missing extra dependencies from thecontrib
extra, @asottile has warned thatIt would be good to look into if there are more reasonable ways to force the reload of the relevant modules to trigger the import error.
In his video testing optional python dependencies (intermediate) Anthony demos using
mock.patch.object
to patch the imported dependency in the module where it is imported. I think there was some reason I didn't end up doing this for the PR in whichcontrib download
was added, but I can't remember why (maybe because I wanted a specific import error?) so this is probably a good place to start revisiting the Issue.This comes up in the context of:
The text was updated successfully, but these errors were encountered: