簡體   English   中英

覆蓋范圍在Travis上失敗,但不在本地計算機上-錯誤取決於標志的順序

[英]Coverage failing on Travis but not on local machine - error depends on order of flags

我的.travis.yml文件中包含以下script部分:

script:
  # run all tests in mymodule/tests and check coverage of the mymodule dir
  # don't report on coverage of files in the mymodule/tests dir itself
  - coverage run -m --source mymodule --omit mymodule/tests/* py.test mymodule/tests -v

這在我自己的(Windows)機器上可以正常工作,但是在Travis構建上的Linux和OSX上都引發錯誤。 錯誤是:

不支持按文件名導入。

使用不同的標志順序,我會看到不同的錯誤(僅在Linux構建上-OSX測試通過標志的此順序通過):

-coverage run --source eppy --omit eppy/tests/* -m py.test eppy/tests -v

在'mymodule / tests / geometry_tests'中找不到'__main__'模塊

我在這里做錯了什么?

通過從直接使用coverage更改為使用pytest-cov

script:
  # run all tests in mymodule/tests and check coverage of the mymodule dir
  - py.test -v --cov-config .coveragerc --cov=mymodule mymodule/tests

.coveragerc文件:

# .coveragerc to control coverage.py
[run]
# don't report on coverage of files in the tests dir itself
omit = 
  mymodule/tests/*

我不知道為什么這種方法在以前的方法無法解決的地方起作用,但這至少可以解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM