I have a "models" folder, inside which i have different models that are used for unit testing. File hierarchy is as follows
- test
- models
- nn_class.sav
- nn_reg.sav
- test_model
I run test_model, which has unit test inside. And when i read the file nn_class.sav
, it works perfectly fine by giving path "./models"
. Whereas when i try to run the same tests on Github, it throws the error of File not found.
I have to use this instead, so it can find files in both environments.
model_name = 'nn_class.sav'
if os.path.isdir('./models'):
path = './models/'
else:
path = 'test/models/'
Is there a nice elegant way to deal with this issue. Someone suggested fixtures to me, i don't know if they'll be helpful.