I have the following folder structure for my tests:
python-tests
tests-folder-1
input-data
<files_with_input_data_for_tests_from_this_folder>
test_1.py
test_2.py
tests-folder-2
input-data
<files_with_input_data_for_tests_from_this_folder>
test_something_else_1.py
test_something_else_2.py
run.py
I want to be able to discover and run all tests at once, but also to be able to run them in isolation. The problem is the tests use external data (saved in input-data
folders), and the run.py
script when run makes the "current working directory" different then when the tests are run in isolation. This results in one of the aforementioned scenarios having the tests failed due to being unable to load the input data.
What would be the best way solve this problem, to be able to run such tests both all at once and in isolation?
The run.py
python script looks as follows:
if __name__ == '__main__':
suite = unittest.TestLoader().discover('.', pattern="test_*.py")
unittest.TextTestRunner(verbosity=2).run(suite)
I would like to avoid modifying sys.path
if possible.
Aucun commentaire:
Enregistrer un commentaire