So I tried many things (from SO and more) getting my tests running but nothing worked this is my current code:
test.py
which I call to run the tests: python3 ./src/preprocess/python/test.py
import unittest
if __name__ == '__main__':
testsuite = unittest.TestLoader().discover('.')
unittest.TextTestRunner(verbosity=2).run(testsuite)
the test file looks like this:
import unittest
from scrapes.pdf import full_path_to_destination_txt_file
print(full_path_to_destination_txt_file)
class PreprocessingTest(unittest.TestCase):
def path_txt_appending(self):
self.assertEqual(full_path_to_destination_txt_file(
"test", "/usr/test"), "/usr/test/test.txt")
if __name__ == '__main__':
unittest.main(verbosity=2)
But the output is always like this:
python3 ./src/preprocess/python/test.py
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
Additional Information:
- As you can see I call this not from my root directory. The test folder is in
./src/preprocess/python/test/
and has a__init__.py
file included (there is also a init file on the level of test.py) - it would be okay for me if I have to code down all the calls for all the tests I just want to finish this
- automatic search with -t does not work either so I thought the more robust method here with test.py would work...
- using this framework is a requirement I have to follow
- test_preprocessing.py is in the test folder and
from scrapes.pdf import full_path_to_destination_txt_file
scrapes is a module folder on the same level as test - When I call the single unit test directly in the command line it fails because of the relative import. But using the test.py (obviously) finds the modules.
What is wrong?