python测试相关小问题

实操中的小问题

pycharm 一次运行多个test configuration

项目分层,分包之后,tests也分到不同层的不同project里了,tests也分开。

为了防止基层模块改动,影响上层,希望一次运行多个test configuration

在edit configuration里,在某一个configuration里添加其他的

tests下文件夹不要和被测module同名

import的低级错误记录:

工程如果长这样:

moduleA

  __init__,py

      B.py

tests

  moduleA

    __init__.py

    test_B.py

test_B.py开头如果import moduleA会报错

在tests路径下,注意一切都要以test开头,现在这么写,表示在tests下面已经有一个同名的组件moduleA了!

   把tests/moduleA改成tests/test_moduleA 就可以了

tests

  test_moduleA

    __init__.py

    test_B.py

原文地址:https://www.cnblogs.com/xuanmanstein/p/8779391.html