所以我尝试了很多事情(从SO and起),但仍未成功,这是我当前的代码:
test.py
,我称之为运行测试:python3 ./src/preprocess/python/test.py
导入unittest
if __name__ == '__main__':
testsuite = unittest.TestLoader().discover('.')
unittest.TextTestRunner(verbosity=2).run(testsuite)
测试文件如下所示:
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)
但是输出始终是这样的:
python3 ./src/preprocess/python/test.py
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
附加信息:
./src/preprocess/python/test/
中,并包含__init__.py
文件(在test.py级别上还有一个初始化文件)from scrapes.pdf import full_path_to_destination_txt_file
scrapes是与测试处于同一级别的模块文件夹怎么了?
[因此,我尝试了很多事情(从SO或更多工具中)来运行测试,但没有任何效果,这是我当前的代码:test.py,我调用它来运行测试:python3 ./src/preprocess/python/test.py。 ..
默认情况下,unittest将仅执行名称以test
开头的方法: