小编Chi*_*ank的帖子

tox中的条件命令?(tox,travis-ci和工作服)

TL;博士:

我正在为我的一个项目设置CI,在github上托管,使用tox和travis-ci.在构建结束时,我converalls会将覆盖率报告推送到coveralls.io.我想让这个命令'有条件' - 只有当测试在travis上运行时才能执行; 不是当他们在我的本地机器上运行时.有没有办法让这种情况发生?

细节:

我正在尝试测试的包是一个python包.我正在使用/计划使用以下"基础架构"来设置测试:

  • 测试本身就是py.test多种多样的.
  • 可以说,CI脚本来自tox.这让我可以在本地运行测试,这对我来说非常重要.我不想每次需要测试运行时都要推送到github.我也用numpy,并matplotlib在我的包,因此在运行测试周期的空洞的数量上travis-ci似乎过于浪费在我身上.因此,放弃tox和.travis.yml单独使用不是一种选择.
  • CI服务器是 travis-ci

相关的测试脚本如下所示:

.travis.yml

language: python
python: 2.7
env:
  - TOX_ENV=py27
install:
  - pip install tox
script:
  - tox -e $TOX_ENV
Run Code Online (Sandbox Code Playgroud)

tox.ini

[tox]
envlist = py27

[testenv]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
deps =
    pytest
    coverage
    pytest-cov
    coveralls
commands =
    py.test --cov={envsitepackagesdir}/mypackage --cov-report=term --basetemp={envtmpdir}
    coveralls
Run Code Online (Sandbox Code Playgroud)

这个文件让我在本地运行测试.但是,由于最后的coveralls呼叫,测试原则上失败了:

py27 …
Run Code Online (Sandbox Code Playgroud)

python travis-ci tox coveralls

19
推荐指数
3
解决办法
1864
查看次数

SQLAlchemy Declarative: How to merge models and existing business logic classes

I would like to know what the best practices are for using SQLALchemy declarative models within business logic code. Perhaps stackexchange.codereview may have a been a better place to ask this, but I'm not sure.

Here's some background.

Let's say I have a bunch of classes doing various things. Most of them have little or nothing to do with each other.Each such class has between a hundred to thousand lines of code doing things that have precious little to do …

python orm design-patterns sqlalchemy

9
推荐指数
1
解决办法
1664
查看次数

标签 统计

python ×2

coveralls ×1

design-patterns ×1

orm ×1

sqlalchemy ×1

tox ×1

travis-ci ×1