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

added extra generator documentation

parent 9b6b2b96
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -48,8 +48,16 @@ class test_generator(object):
	 2) A mapping of keyword arguments, or
	 3) A 2-item object where item 0 matches (1) and item 1 matches (2)

	If the arguments resolve to an empty iterable or `None` no tests will be 
	generated for the test case, although the generator will still be available 
	for sub-classed test cases. (Note: this only makes sense when using named
	arguments.)

	Examples:

	  Pass an arguments list directly to the decorator, the same tests will be 
	  generated in all subclassed test cases as well:

	  ```
	  class TestCase(unittest.TestCase, metaclass=TestGeneratorMeta):

@@ -58,6 +66,9 @@ class test_generator(object):
	          # run test with a & b...
	  ```

	  Pass the name of the arguments list to the generator, the tests will only 
	  be generated for classes that define the named list:

	  ```
	  class TestCase(unittest.TestCase, metaclass=TestGeneratorMeta):

@@ -71,6 +82,8 @@ class test_generator(object):
	          # run test with a & b...
	  ```

	  Pass positional and keyword arguments together:

	  ```
	  class TestCase(unittest.TestCase, metaclass=TestGeneratorMeta):

@@ -83,6 +96,20 @@ class test_generator(object):
	      def some_test(self, a, b, type=None):
	          # run test with a & b...
	  ```

	  A test generator for use by subclasses ONLY, no tests generated in the 
	  class in which it is defined:

	  ```
	  class TestCase(unittest.TestCase, metaclass=TestGeneratorMeta):

	      some_test_args = None

	      @test_generator('some_test_args')
	      def some_test(self, a, b):
	          # no tests in this TestCase, but subclassed TestCases may 
	          # override `some_test_args` to generate tests with this function.
	  ```
	"""

	def __init__(self, values=None):