我有我的所有unittests文件夹。它们都包括:为什么导入*不运行导入的代码?
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())
所以对它们进行测试我只需要导入测试脚本。我有一个test_all脚本,通过逐个导入它们来完成所有的单元测试。目前,这看起来像这样:
from pyMS.test import test_baseFunctions
from pyMS.test import test_compareFeatureXMLmzML
from pyMS.test import test_config
from pyMS.test import test_featureFunctions
from pyMS.test import test_fileHandling
from pyMS.test import test_mzmlFunctions
from pyMS.test import test_output
from pyMS.test import test_parseFeatureXML
from pyMS.test import test_rFunctions
from pyMS.test import test_rPlots
[...]
这意味着每次添加或删除新测试时,我都需要更改导入。因此,我想使用
from pyMS.test import *
但是,这不会运行任何代码。我很好奇导入*不运行代码的原因。 此外,如果有人知道一个解决方案(即笔记鼻子)来运行所有的单元测试,而不必一个一个地导入它们会很好。
感谢
NIEK
'if __name__ == __name __:'?我希望你的意思是'if __name__ =='__main __':'? – 2012-03-15 11:24:21
这看起来不是一种运行所有测试的好方法。 – 2012-03-15 11:31:35
woops呀,这就是我的意思 – 2012-03-15 11:32:14