欢迎来到Nose2
鼻梁2‘S伸展  unittest 让测试变得更好。
鼻子2对鼻子
nose2 起源于作为继任者的  nose 。
nose2 是一个不同的项目,并不支持  nose 。看见  differences 进行一次彻底的总结。
Nose2与Pytest
pytest 是一个很好的测试框架,我们鼓励用户在新项目中考虑它。
它有一个更大的维护团队和更大的用户社区。
快速启动
因为 nose2 基于UnitTest,您可以从Python标准库的 documentation for unittest 然后使用nose2在上面增加值。
nose2 在名称以开头的Python文件中查找测试  test 并运行它发现的每一个测试函数。
下面是一个用典型的UnitTest样式编写的简单测试示例:
# in test_simple.py
import unittest
class TestStrings(unittest.TestCase):
    def test_upper(self):
        self.assertEqual("spam".upper(), "SPAM")
然后您可以这样运行此测试::
$ nose2 -v
test_upper (test_simple.TestStrings) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
然而, nose2 支持更多的测试配置,并提供更多的工具 unittest 靠自己。
例如,这个测试只练习了 nose2 的功能:
# in test_fancy.py
from nose2.tools import params
@params("Sir Bedevere", "Miss Islington", "Duck")
def test_is_knight(value):
    assert value.startswith('Sir')
然后像这样运行:
$ nose2 -v --pretty-assert
test_fancy.test_is_knight:1
'Sir Bedevere' ... ok
test_fancy.test_is_knight:2
'Miss Islington' ... FAIL
test_fancy.test_is_knight:3
'Duck' ... FAIL
======================================================================
FAIL: test_fancy.test_is_knight:2
'Miss Islington'
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/ebs/home/sirosen/tmp/test_fancy.py", line 6, in test_is_knight
    assert value.startswith('Sir')
AssertionError
>>> assert value.startswith('Sir')
values:
    value = 'Miss Islington'
    value.startswith = <built-in method startswith of str object at 0x7f3c3172f430>
======================================================================
FAIL: test_fancy.test_is_knight:3
'Duck'
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/ebs/home/sirosen/tmp/test_fancy.py", line 6, in test_is_knight
    assert value.startswith('Sir')
AssertionError
>>> assert value.startswith('Sir')
values:
    value = 'Duck'
    value.startswith = <built-in method startswith of str object at 0x7f3c3172d490>
----------------------------------------------------------------------
Ran 3 tests in 0.001s
FAILED (failures=2)
完整文档
完整的文档 nose2 可在 docs.nose2.io
版本和支持
更改日志和版本方案
Nose2版本有编号  0.MAJOR.MINOR 。次要版本包含错误修复或较小的功能。在主要版本中完成了主要功能或向后不兼容的更改。
有关所有过去版本和更改的完整说明,请参阅 changelog 。
Python版本
Nose2需要使用Python3。
它支持CPython团队目前支持的所有版本,还旨在支持PyPy和cpythonBeta。
Python 2
不再支持Python2。这个 0.12.x line of releases 包含支持Python2的最新版本。
Python2的用户应该了解,Python2是停产的,其支持行为  nose2 同样被认为是停产。
备注
在一小段时间内,对0.12.x的修复仍然可以根据需要接受,因为只支持python3的一系列版本开始发布。
贡献
如果你想做贡献,请阅读 contributing 指南。
用户指南
- 开始使用Nose2
- 使用 nose2
- 配置nose2
- 差异:nose2与nose与unittest2
- nose2插件
- 工具和助手
- Changelog- 未发布
- 0.15.1(2024-05-31)
- 0.15.0(2024-05-30)
- 0.14.2(2024-05-07)
- 0.14.1(2024-01-28)
- 0.14.0(2023-10-04)
- 0.13.0(2023-04-29)
- 0.12.0(2022-07-16)
- 0.11.0(2022-02-12)
- 0.10.0(2021-01-27)
- 0.9.2(2020-02-02)
- 0.9.1(2019-04-02)
- 0.9.0(2019-03-17)
- 0.8.0(2018-07-31)
- 0.7.4(2018-02-17)
- 0.7.3(2017/12/13)
- 0.7.2(2017/11/14)
- 0.7.0(2017-11-05)
- 0.6.5(2016-06-29)
- 0.6.4(2016-03-15)
- 0.6.3(2016-03-01)
- 0.6.2(2016-02-24)
- 0.6.1(2016-02-23)
- 0.6.0(2016-02-21)
- 0.5.0(2014-09-14)
- 0.4.7(2013-08-13)
- 0.4.6(2013-04-07)
- 0.4.5(2012-12-16)
- 0.4.4(2012-11-26)
- 0.4.3(2012-11-21)
- 0.4.2(2012-11-19)
- 0.4.1(2012-06-18)
- 0.3(2012-04-15)
- 0.2(2012-02-06)
- 0.1(2012-01-19)
 
插件开发人员指南
- 正在写入插件
- 记录插件
- 事件引用- CommandLineArgsEvent
- CreateTestsEvent
- CreatedTestSuiteEvent
- DescribeTestEvent
- Event
- GetTestCaseNamesEvent
- HandleFileEvent
- LoadFromModuleEvent
- LoadFromNameEvent
- LoadFromNamesEvent
- LoadFromTestCaseEvent
- MatchPathEvent
- ModuleSuiteEvent
- OutcomeDetailEvent
- PluginsLoadedEvent
- ReportSummaryEvent
- ReportTestEvent
- ResultCreatedEvent
- ResultStopEvent
- ResultSuccessEvent
- RunnerCreatedEvent
- StartLayerSetupEvent
- StartLayerSetupTestEvent
- StartLayerTeardownEvent
- StartLayerTeardownTestEvent
- StartTestEvent
- StartTestRunEvent
- StopLayerSetupEvent
- StopLayerSetupTestEvent
- StopLayerTeardownEvent
- StopLayerTeardownTestEvent
- StopTestEvent
- StopTestRunEvent
- TestOutcomeEvent
- UserInteractionEvent
 
- 钩参考
- 会话引用
- 插件类引用