I think you need to guard this with:
```python
if tests.MPL_AVAILABLE:
    import matpltlob.pyplot as plt
```