As discussed here, code coverage tools do not work nicely with tensorflow due to its code transformation. One suggested workaround is to use tf.config.experimental_run_functions_eagerly(True) when generating reports (though it's worth noting that this still does not handle all cases, e.g. tf.map_fn).
My question is: is there a simple way to do this automatically for tests run using pytest --cov? Is there perhaps something I could add to conftest.py that would allow me to make all executions run eagerly whenever I pass a given command line argument, such as pytest --cov --eagerly?
Yes, it turns out: