【问题标题】:Why can't CircleCi find my tests?为什么 CircleCi 找不到我的测试?
【发布时间】:2015-06-29 13:12:26
【问题描述】:

请参阅下面的回购结构。我想在 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

【问题讨论】:

    标签: testing circleci


    【解决方案1】:

    好的,在 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
    

    【讨论】:

    • 我试过这个,但我得到“...ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. 这会阻止 urllib3 正确配置 SSL,并可能导致某些 SSL 连接失败。 ...”当它尝试安装 pytest
    【解决方案2】:

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

    您能否尝试用这个替换circle.yml 中的当前命令?

    general:
      build_dir: app2
    

    【讨论】:

      猜你喜欢
      • 2013-04-19
      • 1970-01-01
      • 2012-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      相关资源
      最近更新 更多