0

Importing TensorFlow can take quite a while. Is there a way to mock or ignore TensorFlow while unit-testing functions on the same file that does not depend on TensorFlow?

Rafael Dias
  • 13
  • 1
  • 2
  • See [Mocking a module import in pytest](https://stackoverflow.com/q/43162722/674039) – wim Jun 14 '22 at 12:36
  • Great, thank you. That works, however, it leaves me with another problem. How can I now test the functions that do use TensorFlow in other test files? – Rafael Dias Jun 14 '22 at 13:08
  • Well you won't actually save any time on the import in that case, so you may as well not mock it at all. The import only happens once for the entire test suite. – wim Jun 14 '22 at 13:13
  • humm... I guess you are right, normally that would be the case. It may be because of mlflow that it keeps being imported every time I call a mlflow scope. Thank you for your help. – Rafael Dias Jun 14 '22 at 13:45

0 Answers0