diff options
Diffstat (limited to 'tests/testutils')
-rw-r--r-- | tests/testutils/data.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/testutils/data.py b/tests/testutils/data.py new file mode 100644 index 00000000..c9e233d7 --- /dev/null +++ b/tests/testutils/data.py @@ -0,0 +1,35 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2016 Guido Guenther <agx@sigxcpu.org> +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# <http://www.gnu.org/licenses/> + +from functools import wraps + +import unittest + + +class TestCaseWithData(unittest.TestCase): + @staticmethod + def feed(data): + def wrapper(fn): + @wraps(fn) + def feed_item(self, *args): + for d in data: + try: + fn(self, *((d,) + args)) + except self.failureException as e: + raise self.failureException(e.message + " with data %s" % repr(d)) + return feed_item + return wrapper |