gpt4 book ai didi

python - 如何使用 travis-ci.org 测试需要键盘输入的项目?

转载 作者:行者123 更新时间:2023-11-28 21:47:03 24 4
gpt4 key购买 nike

我正在尝试在 travis-ci(持续集成平台)中测试一个简单的菜单算法,该算法等待用户输入以执行任务(CRUD)喜欢:

显示、添加、删除、更新注册表或退出。

示例代码如下:

Python Code

这是我的 .travis.yml 文件:

language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev" # 3.5 development branch
- "nightly" # currently points to 3.6-dev
# command to install dependencies
# install: "pip install -r requirements.txt"
# command to run tests
script:
- python 1aula_agenda.py

这是 travis-ci.org 的输出:

0.00s$ source ~/virtualenv/python2.7/bin/activate
$ python --version
Python 2.7.9
$ pip --version
pip 6.0.7 from /home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages (python 2.7)
Could not locate requirements.txt. Override the install: key in your .travis.yml to install dependencies.
$ python 1aula_agenda.py
0. Visualizar
1. Inserir um contato
2. Remover um contato
3. Alterar um contato
4. Sair do programa
Escolha uma opcao:
No output has been received in the last 10 minutes, this potentially indicates a stalled build or something wrong with the build itself.
The build has been terminated

我怎样才能让 travis 测试所有选项012 , 3, 4 并在选项 1 和 3 的情况下添加名称和数字?

最佳答案

可以创建一个带有电池测试的文件testing.txt来测试程序的功能。

testing.txt 包含程序所需的键盘输入。 例如测试你的例子

0
1
"John Smith"
"1235-5387"
0
4

并在 .travis.yml 文件中包含 testing.txt:

language: python
python:
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
- "3.5-dev" # 3.5 development branch
- "nightly" # currently points to 3.6-dev
# command to install dependencies
# install: "pip install -r requirements.txt"
# command to run tests
script:
- python 1aula_agenda.py < testing.txt

关于python - 如何使用 travis-ci.org 测试需要键盘输入的项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37107609/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com