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 75 76 77
|
# coding: utf-8
from __future__ import unicode_literals
import six
from genty import genty_dataset, genty, genty_args
from genty.private import format_arg
from test.test_case_base import TestCase
@genty
class GentyArgsTest(TestCase):
"""Tests for :mod:`box.test.genty.genty_args`."""
@genty_dataset(
(4, 3, 2),
('a', 'b', 'c'),
)
def test_genty_args_saves_args(self, *args):
gargs = genty_args(*args)
self.assertItemsEqual(gargs.args, args)
@genty_dataset(
{
'orange': 'orange',
'banana': 'yellow'
},
{},
)
def test_genty_args_saves_kwargs(self, kwargs_dict):
gargs = genty_args(**kwargs_dict)
self.assertItemsEqual(gargs.kwargs, kwargs_dict)
@genty_dataset(
((4, 3, 2), {'orange': 'orange', 'banana': 'yellow'}),
(('a', 'b', 'c'), {}),
)
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)
@genty_dataset(
(4, 3, 2),
('a', 'b', 'c'),
)
def test_genty_args_yields_formatted_args(self, *args):
gargs = genty_args(*args)
self.assertItemsEqual(
gargs,
(format_arg(arg) for arg in args),
)
@genty_dataset(
{
'orange': 'orange',
'banana': 'yellow'
},
{},
)
def test_genty_args_yields_kwargs(self, kwargs_dict):
gargs = genty_args(**kwargs_dict)
for fruit, color in six.iteritems(kwargs_dict):
self.assertIn('{0}={1}'.format(fruit, repr(color)), gargs)
@genty_dataset(
((4, 3, 2), {'orange': 'orange', 'banana': 'yellow'}),
(('a', 'b', 'c'), {}),
)
def test_genty_args_yields_args_and_kwargs(self, args_tuple, kwargs_dict):
gargs = genty_args(*args_tuple, **kwargs_dict)
for fruit, color in six.iteritems(kwargs_dict):
self.assertIn('{0}={1}'.format(fruit, repr(color)), gargs)
for arg in args_tuple:
formatted_arg = format_arg(arg)
self.assertIn(formatted_arg, gargs)
|