Commit ffb962d9 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

added filtering of argument lists with a function

parent ae6c8e49
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -112,12 +112,13 @@ class test_generator(object):
	  ```
	"""

	def __init__(self, values=None):
	def __init__(self, values=None, filter=None):
		assert not isinstance(values, Callable) \
		       or isinstance(values, Iterable), \
			"You must use an instance of {0}, not {0} itself as a test " \
			"decorator.".format(self.__class__.__name__)
		self.values = values
		self.filter = filter

	def __call__(self, func):
		self.func = func
@@ -157,6 +158,8 @@ class test_generator(object):
			else:
				args = values,
				kwds = {}
			if self.filter and not self.filter(args, kwds):
				continue
			wrapper = self._make_wrap(tuple(args), dict(kwds))
			yield (None if unnumbered else number), wrapper