我有一个文件test_gather.py
import gather
class TestGather(unittest.TestCase):
def test_01_gather(self):
self.assertEqual(len(gather.lookup_terms) > 2, True)
if __name__ == '__main__':
unittest.main()
这在 coveralls 中运行,但是从未到达最后一行。 (https://coveralls.io/builds/3180464/source?filename=tests%2Ftest_gather.py)
我的travis.yaml
位于以下位置:
language: python
python:
- "3.4"
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
install:
- pip install .
- pip install coverage
- pip install nose coverage
- pip install coveralls
script:
- python setup.py nosetests --with-coverage --cover-package pypiview
- coverage run --source=rawdata setup.py test
- nosetests --with-coverage
after_success:
coveralls
如何配置此项以确保所有tests/test_*.py
个文件都运行,以便最后一行也被执行?
答案 0 :(得分:1)
您正在使用测试发现来查找和运行测试。你根本不需要if __name__
条款。只需将其删除即可。