Add `@idata(iterable)` decorator-function.

The purpose is to avoid:: 

  @data(*[a for a in foo if a > 0])
This commit is contained in:
Kostis Anagnostopoulos 2016-02-22 23:45:47 +01:00
parent 2d0a689d3a
commit 347fe29fe8
1 changed files with 11 additions and 1 deletions

12
ddt.py
View File

@ -58,9 +58,19 @@ def data(*values):
Should be added to methods of instances of ``unittest.TestCase``.
"""
return idata(values)
def idata(iterable):
"""
Method decorator to add to your test methods.
Should be added to methods of instances of ``unittest.TestCase``.
"""
def wrapper(func):
setattr(func, DATA_ATTR, values)
setattr(func, DATA_ATTR, iterable)
return func
return wrapper