3

请参阅下面的回购结构。我想在 root/app2/tests/ 中运行测试。我正在使用 py.test。

在 CircleCi 无法自动推断测试目录后,我在根目录中添加了一个 circle.yml 文件,但仍然找不到测试。非常感谢任何帮助。

circle.yml 文件内容:

general:
  build_dir: app2/tests

存储库结构:

root
├── circle.yml
├── app1
│   ├── xxx
│   ├── yyy
│  
└── app2
    ├── src
    ├── tests
        |-- test_module_1.py
        |-- test_module_2.py
4

2 回答 2

5

好的,在 CircleCI 的帮助下,我想出了如何将 py.test 与 CircleCI 一起使用:

circle.yml文件中添加:

test:
    override:
        - py.test <optional path to subdir with tests>

dependencies:
    pre:
       -  pip install pytest

如果您的代码除了 py.test 还依赖于几个包,您可以创建一个 requirements.txt 文件:

pip freeze > requirements.txt

将 requirements.txt 文件放在与 circle.yml 文件相同的目录中(如果您在 circle.yml 文件中指定,则放在 build_dir 中)并添加到 circle.yml:

dependencies:
      pre:
         -  pip install -r requirements.txt
于 2015-06-29T17:11:12.590 回答
0

通常将 设置build_dir为仅应用程序目录就足够了,我们将自己负责查找测试子目录。

你能试着用circle.yml这个替换你当前的命令吗?

general:
  build_dir: app2
于 2015-06-29T13:58:58.050 回答