Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-ddt for openSUSE:Factory checked in at 2021-10-20 20:23:31 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-ddt (Old) and /work/SRC/openSUSE:Factory/.python-ddt.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-ddt" Wed Oct 20 20:23:31 2021 rev:15 rq:925752 version:1.4.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-ddt/python-ddt.changes 2021-04-12 12:33:41.633047473 +0200 +++ /work/SRC/openSUSE:Factory/.python-ddt.new.1890/python-ddt.changes 2021-10-20 20:24:17.781378522 +0200 @@ -1,0 +2,7 @@ +Sat Oct 16 21:01:08 UTC 2021 - Dirk M??ller <dmuel...@suse.com> + +- update to 1.4.4: + * Fix the ddt.idata signature issue introduced in 1.4.3 + * Fix zero padding issue + +------------------------------------------------------------------- Old: ---- ddt-1.4.2.tar.gz New: ---- ddt-1.4.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-ddt.spec ++++++ --- /var/tmp/diff_new_pack.uhhFMP/_old 2021-10-20 20:24:18.233378801 +0200 +++ /var/tmp/diff_new_pack.uhhFMP/_new 2021-10-20 20:24:18.233378801 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without python2 Name: python-ddt -Version: 1.4.2 +Version: 1.4.4 Release: 0 Summary: Data-Driven/Decorated Tests License: MIT ++++++ ddt-1.4.2.tar.gz -> ddt-1.4.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.4.2/PKG-INFO new/ddt-1.4.4/PKG-INFO --- old/ddt-1.4.2/PKG-INFO 2021-03-12 21:36:29.390868000 +0100 +++ new/ddt-1.4.4/PKG-INFO 2021-10-05 00:43:33.093427700 +0200 @@ -1,12 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: ddt -Version: 1.4.2 +Version: 1.4.4 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/datadriventests/ddt Author: Carles Barrob??s Author-email: car...@barrobes.com License: UNKNOWN -Description: A library to multiply test cases Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers @@ -18,3 +17,7 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Software Development :: Testing +License-File: LICENSE.md + +A library to multiply test cases + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.4.2/ddt.egg-info/PKG-INFO new/ddt-1.4.4/ddt.egg-info/PKG-INFO --- old/ddt-1.4.2/ddt.egg-info/PKG-INFO 2021-03-12 21:36:29.000000000 +0100 +++ new/ddt-1.4.4/ddt.egg-info/PKG-INFO 2021-10-05 00:43:32.000000000 +0200 @@ -1,12 +1,11 @@ -Metadata-Version: 1.1 +Metadata-Version: 2.1 Name: ddt -Version: 1.4.2 +Version: 1.4.4 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/datadriventests/ddt Author: Carles Barrob??s Author-email: car...@barrobes.com License: UNKNOWN -Description: A library to multiply test cases Platform: UNKNOWN Classifier: Development Status :: 4 - Beta Classifier: Intended Audience :: Developers @@ -18,3 +17,7 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Software Development :: Testing +License-File: LICENSE.md + +A library to multiply test cases + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.4.2/ddt.py new/ddt-1.4.4/ddt.py --- old/ddt-1.4.2/ddt.py 2021-03-12 21:36:19.000000000 +0100 +++ new/ddt-1.4.4/ddt.py 2021-10-05 00:43:21.000000000 +0200 @@ -20,7 +20,7 @@ else: _have_yaml = True -__version__ = '1.4.2' +__version__ = '1.4.4' # These attributes will not conflict with any real python attribute # They are added to the decorated test method and processed later @@ -30,7 +30,7 @@ FILE_ATTR = '%file_path' # store the path to JSON file YAML_LOADER_ATTR = '%yaml_loader' # store custom yaml loader for serialization UNPACK_ATTR = '%unpack' # remember that we have to unpack values -index_len = 5 # default max length of case index +INDEX_LEN = '%index_len' # store the index length of the data try: @@ -90,21 +90,30 @@ Should be added to methods of instances of ``unittest.TestCase``. """ - global index_len - index_len = len(str(len(values))) return idata(values) -def idata(iterable): +def idata(iterable, index_len=None): """ Method decorator to add to your test methods. Should be added to methods of instances of ``unittest.TestCase``. - """ + :param iterable: iterable of the values to provide to the test function. + :param index_len: an optional integer specifying the width to zero-pad the + test identifier indices to. If not provided, this will add the fewest + zeros necessary to make all identifiers the same length. + """ + if index_len is None: + # Avoid consuming a one-time-use generator. + iterable = tuple(iterable) + index_len = len(str(len(iterable))) + def wrapper(func): setattr(func, DATA_ATTR, iterable) + setattr(func, INDEX_LEN, index_len) return func + return wrapper @@ -138,7 +147,7 @@ return wrapper -def mk_test_name(name, value, index=0, name_fmt=TestNameFormat.DEFAULT): +def mk_test_name(name, value, index=0, index_len=5, name_fmt=TestNameFormat.DEFAULT): """ Generate a new name for a test case. @@ -264,13 +273,14 @@ """ Add tests from data loaded from the data file into the class """ + index_len = len(str(len(data))) for i, elem in enumerate(data): if isinstance(data, dict): key, value = elem, data[elem] - test_name = mk_test_name(name, key, i) + test_name = mk_test_name(name, key, i, index_len) elif isinstance(data, list): value = elem - test_name = mk_test_name(name, value, i) + test_name = mk_test_name(name, value, i, index_len) if isinstance(value, dict): add_test(cls, test_name, test_name, func, **value) else: @@ -332,11 +342,13 @@ def wrapper(cls): for name, func in list(cls.__dict__.items()): if hasattr(func, DATA_ATTR): + index_len = getattr(func, INDEX_LEN) for i, v in enumerate(getattr(func, DATA_ATTR)): test_name = mk_test_name( name, getattr(v, "__name__", v), i, + index_len, fmt_test_name ) test_data_docstring = _get_test_data_docstring(func, v) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.4.2/test/test_example.py new/ddt-1.4.4/test/test_example.py --- old/ddt-1.4.2/test/test_example.py 2021-03-12 21:36:19.000000000 +0100 +++ new/ddt-1.4.4/test/test_example.py 2021-10-05 00:43:21.000000000 +0200 @@ -1,6 +1,7 @@ +import itertools import unittest -from ddt import ddt, data, file_data, unpack +from ddt import ddt, data, file_data, idata, unpack from test.mycode import larger_than_two, has_three_elements, is_a_greeting try: @@ -64,6 +65,12 @@ a, b = value self.assertGreater(a, b) + @idata(itertools.product([0, 1, 2], [3, 4, 5])) + def test_iterable_argument(self, value): + first_value, second_value = value + self.assertLessEqual(first_value, 2) + self.assertGreaterEqual(second_value, 3) + @data(annotated2([2, 1], 'Test_case_1', """Test docstring 1"""), annotated2([10, 5], 'Test_case_2', """Test docstring 2""")) def test_greater_with_name_docstring(self, value): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.4.2/test/test_functional.py new/ddt-1.4.4/test/test_functional.py --- old/ddt-1.4.2/test/test_functional.py 2021-03-12 21:36:19.000000000 +0100 +++ new/ddt-1.4.4/test/test_functional.py 2021-10-05 00:43:21.000000000 +0200 @@ -9,7 +9,7 @@ except ImportError: import mock -from ddt import ddt, data, file_data, TestNameFormat +from ddt import ddt, data, file_data, idata, TestNameFormat from test.mycode import has_three_elements @@ -114,11 +114,12 @@ dh_keys = set(data_hello.__dict__.keys()) post_size = len(data_hello.__dict__) - assert post_size == pre_size + 1 - extra_attrs = dh_keys - keys - assert len(extra_attrs) == 1 - extra_attr = extra_attrs.pop() - assert getattr(data_hello, extra_attr) == (1, 2) + assert post_size == pre_size + 2 + extra_attrs = list(dh_keys - keys) + extra_attrs.sort() + assert len(extra_attrs) == 2 + assert getattr(data_hello, extra_attrs[0]) == 1 + assert getattr(data_hello, extra_attrs[1]) == (1,2) def test_file_data_decorator_with_dict(): @@ -135,13 +136,13 @@ dh_keys = set(data_hello.__dict__.keys()) post_size = len(data_hello.__dict__) - - assert post_size == pre_size + 1 - extra_attrs = dh_keys - keys - - assert len(extra_attrs) == 1 - extra_attr = extra_attrs.pop() - assert getattr(data_hello, extra_attr) == ("test_data_dict.json",) + assert post_size == pre_size + 2 + + extra_attrs = list(dh_keys - keys) + extra_attrs.sort() + assert len(extra_attrs) == 2 + assert getattr(data_hello, extra_attrs[0]) == 1 + assert getattr(data_hello, extra_attrs[1]) == ("test_data_dict.json",) def _is_test(x): @@ -184,6 +185,97 @@ assert ("test_something_{}_{}".format(i, d) in tests) +def test_idata_single_argument(): + """Test that the single-argument form of ``idata`` works.""" + payload = [5, 12, 13] + + @ddt + class Dummy(object): + """Dummy class to test that the ``idata(iterable)`` decorator works.""" + @idata(payload) + def test_something(self, value): + return value + + tests = list(filter(_is_test, Dummy.__dict__)) + assert len(tests) == len(payload) + + expected_tests = [ + "test_something_{:1d}_{}".format(i + 1, v) for i, v in enumerate(payload) + ] + assert sorted(tests) == sorted(expected_tests) + + +def test_idata_automatic_zero_padding(): + """ + Test that the single-argument form of ``idata`` zero-pads its keys so the + lengths all match + """ + payload = range(15) + + @ddt + class Dummy(object): + """Dummy class to test that the ``idata(iterable)`` decorator works.""" + @idata(payload) + def test_something(self, value): + return value + + tests = list(filter(_is_test, Dummy.__dict__)) + assert len(tests) == len(payload) + + expected_tests = [ + "test_something_{:02d}_{}".format(i + 1, v) for i, v in enumerate(payload) + ] + assert sorted(tests) == sorted(expected_tests) + + +def test_idata_override_index_len(): + """ + Test that overriding ``index_len`` in ``idata`` can allow additional + zero-padding to be added. + """ + payload = [4, 2, 1] + + @ddt + class Dummy(object): + @idata(payload, index_len=2) + def test_something(self, value): + return value + + tests = list(filter(_is_test, Dummy.__dict__)) + assert len(tests) == len(payload) + + expected_tests = [ + "test_something_{:02d}_{}".format(i + 1, v) for i, v in enumerate(payload) + ] + assert sorted(tests) == sorted(expected_tests) + + +def test_idata_consumable_iterator(): + """ + Test that using ``idata`` with a consumable iterator still generates the + expected tests. + """ + payload = [51, 78, 2] + + def consumable_iterator(): + # Not using `yield from` for Python 2.7. + for i in payload: + yield i + + @ddt + class Dummy(object): + @idata(consumable_iterator()) + def test_something(self, value): + return value + + tests = list(filter(_is_test, Dummy.__dict__)) + + expected_tests = [ + "test_something_{:1d}_{}".format(i + 1, v) for i, v in enumerate(payload) + ] + assert sorted(tests) == sorted(expected_tests) + + def test_file_data_test_creation(): """ Test that the ``file_data`` decorator creates two tests