/usr/lib/python2.7/dist-packages/nose2/tools/params.py is in python-nose2 0.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | """
This module contains some code copied from unittest2 and other
code developed in reference to unittest2.
unittest2 is Copyright (c) 2001-2010 Python Software Foundation; All
Rights Reserved. See: http://docs.python.org/license.html
"""
import itertools
__unittest = True
def cartesian_params(*paramList):
"""Make a test function or method parameterized by cartesian product
of parameters
.. code-block :: python
import unittest
from nose2.tools import cartesian_params
@cartesian_params((1, 2, 3), ('a', 'b'))
def test_nums(num, char):
assert num < ord(char)
class Test(unittest.TestCase):
@cartesian_params((1, 2, 3), ('a', 'b'))
def test_less_than(self, num, char):
self.assertLess(num, ord(char))
Parameters in the list must be defined as iterable objects such as
tuple or list.
"""
def decorator(func):
func.paramList = itertools.product(*paramList)
return func
return decorator
def params(*paramList):
"""Make a test function or method parameterized by parameters.
.. code-block :: python
import unittest
from nose2.tools import params
@params(1, 2, 3)
def test_nums(num):
assert num < 4
class Test(unittest.TestCase):
@params((1, 2), (2, 3), (4, 5))
def test_less_than(self, a, b):
assert a < b
Parameters in the list may be defined as simple values, or as
tuples. To pass a tuple as a simple value, wrap it in another tuple.
"""
def decorator(func):
func.paramList = paramList
return func
return decorator
|