Example #1
0
 class SomeClass(object):
     @genty_dataset((100, 10), (200, 20),
                    genty_args(110, 50),
                    genty_args(val=120, other=80),
                    genty_args(500, other=50),
                    some_values=(250, 10),
                    other_values=(300, 30),
                    more_values=genty_args(400, other=40))
     def test_something(self, val, other):
         return val + other + 1
Example #2
0
 def test_genty_args_yields_args_and_kwargs(self, args_tuple, kwargs_dict):
     gargs = genty_args(*args_tuple, **kwargs_dict)
     for fruit, color in kwargs_dict.iteritems():
         self.assertIn('{}={}'.format(fruit, repr(color)), gargs)
     for arg in args_tuple:
         formatted_arg = repr(arg) if isinstance(arg, basestring) else unicode(arg)
         self.assertIn(formatted_arg, gargs)
Example #3
0
class ExampleTests(TestCase):
    @genty_repeat(10)
    def test_example_of_repeat(self):
        """This test will be run 10 times"""
        pass

    @genty_dataset('red', 'orange', 'blue')
    def test_example_of_single_parameter_datasets(self, _color):
        """This test will be called 3 times, each time with a different color"""
        pass

    @genty_dataset(*product([True, False], [True, False]))
    def test_example_of_multiple_parameter_datasets(self, _first_bool,
                                                    _second_bool):
        """This test is called 4 times"""
        pass

    @genty_dataset(
        some_test_case=(10, 'happy', unicode),
        another_test_case=(7, 'sleepy', float),
    )
    def test_example_of_named_datasets(self, value, message, kind):
        """This test is called for each of the 2 named datasets"""
        pass

    @genty_dataset(('first', 'second', 'third'),
                   genty_args('first', 'second', 'third'),
                   genty_args('first',
                              third_value='third',
                              second_value='second'))
    def test_example_of_datasets_with_kwargs(self,
                                             first_value,
                                             second_value=None,
                                             third_value=None):
        """This test is called twice, with the arguments ('first', 'second', 'third').
        Note that it is not called three times, because the first and second datasets are identical."""
        pass

    @genty_repeat(4)
    @genty_dataset('first', 'second', 'third')
    def test_example_of_repeat_and_datasets(self, parameter_value):
        """This test will be called 4 times for each of the 3 possible parameter_values"""
        pass
Example #4
0
 def test_genty_args_yields_kwargs(self, kwargs_dict):
     gargs = genty_args(**kwargs_dict)
     for fruit, color in kwargs_dict.iteritems():
         self.assertIn('{}={}'.format(fruit, repr(color)), gargs)
Example #5
0
 def test_genty_args_yields_formatted_args(self, *args):
     gargs = genty_args(*args)
     self.assertItemsEqual(
         gargs,
         (repr(arg) if isinstance(arg, basestring) else unicode(arg) for arg in args),
     )
Example #6
0
 def test_genty_args_saves_args_and_kwargs(self, args_tuple, kwargs_dict):
     gargs = genty_args(*args_tuple, **kwargs_dict)
     self.assertItemsEqual(gargs.args, args_tuple)
     self.assertItemsEqual(gargs.kwargs, kwargs_dict)
Example #7
0
 def test_genty_args_saves_kwargs(self, kwargs_dict):
     gargs = genty_args(**kwargs_dict)
     self.assertItemsEqual(gargs.kwargs, kwargs_dict)
Example #8
0
 def test_genty_args_saves_args(self, *args):
     gargs = genty_args(*args)
     self.assertItemsEqual(gargs.args, args)