Autotest uses metrics through chromite.lib. If site-packages are not setup (e.g., in test_droid run), the import will fail.
In autotest code, there are various places we do something like:
try:
from chromite.lib import metrics
except ImportError:
metrics = None
When metrics is used, we do:
if metrics:
metrics.call(...)
The if check is tedious and easy to forget. We need a better way to handle such issue. One way to do this is through a mock object which can do noops when metrics module is referenced.
Comment 1 by bugdroid1@chromium.org
, Feb 5 2017