JS>> dado>> 返回
项目作者: notion

项目描述 :
Data-driven test decorator
高级语言: Python
项目地址: git://github.com/notion/dado.git
创建时间: 2016-09-16T14:17:47Z
项目社区:https://github.com/notion/dado

开源协议:Apache License 2.0

下载


dado

Data-driven test decorator

What

Decorate a test to create indepenent tests for each decorated data set.

Example

Given:

  1. from dado import data_driven
  2. @data_driven(['first', 'second'], {
  3. 'letters': ['a', 'b'],
  4. 'numbers': [0, 1],
  5. })
  6. def test_first_two(first, second): ...

When you load the module, it will load as if you’d defined:

  1. def test_first_two_letters():
  2. return test_first_two('a', 'b')
  3. def test_first_two_numbers():
  4. return test_first_two(0, 1)

Name

A ‘dado’ in woodworking is “a groove cut in the face of a board, into which the edge of another board is fixed.”

This decorator lets you define a test function into which you fit test data to get the tests you actually want to run.

Plus, ‘dado’ is much easier to say and remember than ‘data-driven-test-decorator’, while still keeping some phonetic
similarity.

Naming credit goes to soapko :-)