Windows无法识别Nosetests

问题描述 投票:1回答:1

我有一个由Travis在Linux和Windows上构建的软件包。用鼻子进行测试。

nosetests --with-coverage --cover-package=terminalplot

在Linux上,所有4个测试均已成功执行。

$ nosetests --with-coverage --cover-package=terminalplot

....
Name                           Stmts   Miss  Cover
--------------------------------------------------
terminalplot/__init__.py           1      0   100%
terminalplot/command.py           25     11    56%
terminalplot/terminalplot.py      27      3    89%
terminalplot/version.py            1      0   100%
--------------------------------------------------
TOTAL                             54     14    74%
----------------------------------------------------------------------

Ran 4 tests in 0.013s

Linux result

在Windows上,同样的代码运行也没有错误,但是报告说未执行任何测试。

$ nosetests --with-coverage --cover-package=terminalplot

The command "nosetests --with-coverage --cover-package=terminalplot" exited with 0.

Coveralls报告说某些部分已经覆盖,所以我认为已经运行了。

$ coveralls

Name                           Stmts   Miss  Cover
--------------------------------------------------
terminalplot\__init__.py           1      0   100%
terminalplot\terminalplot.py      27     23    15%
--------------------------------------------------
TOTAL                             28     23    18%
----------------------------------------------------------------------

Ran 0 tests in 0.016s

Windows result

测试位于单元测试类的测试包中。显然,这些测试是在Linux上轻易找到的,我不知道为什么在Windows上找不到这些测试。

项目结构

.
+- terminalplot
|  +- test
|  |  +- __init__.py
|  |  +- test_terminalplot.py
|  |
|  +- __init__.py
|  +- terminalplot.py
|  +- ...
|
+- ...

测试看起来像下面的测试

import unittest

class TestCommand(unittest.TestCase):

    def test_list_floats(self):
        self.assertEqual(cli.list_floats("1 0.1 -0.3"), [1, 0.1, -0.3])

完整代码在Github

由于我只能访问Linux,因此我只能在Travis上尝试Windows方面的东西。这是相当乏味的。所以我希望有人能指出我正确的方向。

python windows nose
1个回答
0
投票

在Windows上,将--exe标志添加到鼻子测试命令:

nosetests --exe --with-coverage --cover-package=terminalplot

© www.soinside.com 2019 - 2024. All rights reserved.