I am in as situation where I am using a module as an optional package. My goal is to make the test succeed even if I do not have that optional package installed.
The problem is I need to inherit some classes from that module. Even if I skip the tests, pytest gathers all the files and throws an error while gathering the file that is inheriting the class.
Is there a way to ask pytest to ignore this file if a certain module does not exist?
For example,
if have_tf and have_tfa:
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Layer
This I can do, but
class UNet3D(Layer):
Throws an error because it fails to find Layer if tensorflow is not installed while gathering the files.
Could there be a way? I could lose all the inheritence, but that would make the code super messy.
Thank you!