Mousius commented on a change in pull request #9074:
URL: https://github.com/apache/tvm/pull/9074#discussion_r717603997
##########
File path: tests/python/driver/tvmc/test_frontends.py
##########
@@ -211,3 +212,43 @@ def
test_load_model___wrong_language__to_pytorch(tflite_mobilenet_v1_1_quant):
model_format="pytorch",
shape_dict={"input": [1, 3, 224, 224]},
)
+
+
[email protected]("tvm.driver.tvmc.frontends.import_keras")
+def test_import_keras_friendly_message(import_keras_mock, keras_resnet50):
+ import_keras_mock.side_effect = TVMCException("keras is not installed")
Review comment:
It'd be something like this with `@mock`:
```python
def mock_imports(name, *args):
if name == 'onnx':
raise ImportError()
return orig_import(name, *args)
@mock.patch('__builtin__.__import__', side_effect=mock_imports)
```
Or with `monkeypatch` fixture:
```python
def test_import_keras_friendly_message(import_keras_mock, keras_resnet50,
monkeypatch):
monkeypatch.setattr(__builtin__, '__import__', mock_imports);
```
It's dangerous in either case but given it falls back to the default
behaviour for anything else and should be cleaned up after the test it should
be stable? We **want** it to catch all imports for any nested `tflite`s or
`onnx`s right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]