Skip to content Skip to sidebar Skip to footer

How Can I Get Travis-ci To Recognize And Open External Files During Testing

The last few failing builds pass fine on my computer, but I am having trouble getting them to pass on travis. The problem is coming from there few lines in the tests (and other si

Solution 1:

./ is redundant; the path to the file is already relative to your current working directory.

The problem is that you want it to instead be relative to your test directory, so:

import os
# ...

with open(os.path.join(os.path.dirname(__file__), 'soup_1899_pickle.pkl'), 'rb') as soup_pickle:

Solution 2:

I had the same problem, where running the test would work well on mac system but got a FileNotFoundError when I tried to run tests on travis CI or ubuntu. Travis CI uses an ubuntu system. Say you have a folder structure:

project_folder:
|
+---file1.py
+---output_folder
    |
    +---output.txt

If your 'file1.py' has an open() function inside it that is supposed to either create the output folder and the 'output.txt' file, then running tests on ubuntu system expects you to already have the 'output_folder' on your system, or in your github repo. 'output.txt' file doesnt have to be present but the folder should. So if you have added the folder to .gitignore, then you might need to remove it. Hope that helps.

Post a Comment for "How Can I Get Travis-ci To Recognize And Open External Files During Testing"