Commit 2d0d46f4 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

test_generator: None or no args to generate single test

Generate a single, unnumbered, zero-argument test method by creating
a test_generator decorator with no arguments or the first argument as
None.
parent 673146f3
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -97,12 +97,18 @@ class test_generator(object):
		"""
		Generate a test-wrapper with each set of arguments and add it to 'attr'.
		"""
		if isinstance(self.values, string_types):
		if self.values is None:
			# __init__ passed a None or no args; single test without arguments
			wrap = self._make_wrap(tuple(), dict())
			setattr(testcase_class, 'test_{0}'.format(wrap.__name__), wrap)
			return
		elif isinstance(self.values, string_types):
			values = getattr(testcase_class, self.values)
		else:
			values = self.values
			if values is None:
				# ignore; a subclasses will make use of this test generator.
				return
		else:
			values = self.values
		for name, func in self._wrap(values):
			setattr(testcase_class, name, func)