python中单元测试/数据库预处理的技巧

假设文件结构:
pkg/
  __init__.py
  components/
    core.py
    __init__.py
  tests/
    core_test.py
    __init__.py


python -m 你的测试/预处理文件,即为
python -m pkg.tests.core_test.py

 

更多参考这里:http://stackoverflow.com/questions/11536764/attempted-relative-import-in-non-package-even-with-init-py

 
posted @ 2015-04-08 09:19  tommy.yu  阅读(486)  评论(0编辑  收藏  举报