Hello community, here is the log from the commit of package python-ddt for openSUSE:Factory checked in at 2015-12-23 09:57:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-ddt (Old) and /work/SRC/openSUSE:Factory/.python-ddt.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-ddt" Changes: -------- --- /work/SRC/openSUSE:Factory/python-ddt/python-ddt.changes 2015-06-11 08:21:53.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-ddt.new/python-ddt.changes 2015-12-23 09:57:30.000000000 +0100 @@ -1,0 +2,7 @@ +Tue Dec 15 21:55:39 UTC 2015 - [email protected] + +- update to 1.0.1: + * specify minimum version of six + * Fix different test names with different runs + +------------------------------------------------------------------- @@ -66 +72,0 @@ - Old: ---- ddt-1.0.0.tar.gz New: ---- ddt-1.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-ddt.spec ++++++ --- /var/tmp/diff_new_pack.3VI1ap/_old 2015-12-23 09:57:31.000000000 +0100 +++ /var/tmp/diff_new_pack.3VI1ap/_new 2015-12-23 09:57:31.000000000 +0100 @@ -17,7 +17,7 @@ Name: python-ddt -Version: 1.0.0 +Version: 1.0.1 Release: 0 Summary: Data-Driven/Decorated Tests License: MIT ++++++ ddt-1.0.0.tar.gz -> ddt-1.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.0/PKG-INFO new/ddt-1.0.1/PKG-INFO --- old/ddt-1.0.0/PKG-INFO 2015-01-27 19:41:48.000000000 +0100 +++ new/ddt-1.0.1/PKG-INFO 2015-11-18 23:09:54.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: ddt -Version: 1.0.0 +Version: 1.0.1 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/txels/ddt Author: Carles Barrobés diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.0/ddt.egg-info/PKG-INFO new/ddt-1.0.1/ddt.egg-info/PKG-INFO --- old/ddt-1.0.0/ddt.egg-info/PKG-INFO 2015-01-27 19:41:47.000000000 +0100 +++ new/ddt-1.0.1/ddt.egg-info/PKG-INFO 2015-11-18 23:09:54.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: ddt -Version: 1.0.0 +Version: 1.0.1 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/txels/ddt Author: Carles Barrobés diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.0/ddt.py new/ddt-1.0.1/ddt.py --- old/ddt-1.0.0/ddt.py 2015-01-27 19:40:45.000000000 +0100 +++ new/ddt-1.0.1/ddt.py 2015-11-18 23:09:00.000000000 +0100 @@ -9,10 +9,9 @@ import json import os import re -import sys from functools import wraps -__version__ = '1.0.0' +__version__ = '1.0.1' # These attributes will not conflict with any real python attribute # They are added to the decorated test method and processed later @@ -23,6 +22,20 @@ UNPACK_ATTR = '%unpack' # remember that we have to unpack values +try: + trivial_types = (type(None), bool, int, float, basestring) +except NameError: + trivial_types = (type(None), bool, int, float, str) + + +def is_trivial(value): + if isinstance(value, trivial_types): + return True + elif isinstance(value, (list, tuple)): + return all(map(is_trivial, value)) + return False + + def unpack(func): """ Method decorator to add unpack feature. @@ -70,14 +83,6 @@ return wrapper -def is_hash_randomized(): - return (((sys.hexversion >= 0x02070300 and - sys.hexversion < 0x03000000) or - (sys.hexversion >= 0x03020300)) and - sys.flags.hash_randomization and - 'PYTHONHASHSEED' not in os.environ) - - def mk_test_name(name, value, index=0): """ Generate a new name for a test case. @@ -86,47 +91,18 @@ string representation of the value, and convert the result into a valid python identifier by replacing extraneous characters with ``_``. - If hash randomization is enabled (a feature available since 2.7.3/3.2.3 - and enabled by default since 3.3) and a "non-trivial" value is passed - this will omit the name argument by default. Set `PYTHONHASHSEED` - to a fixed value before running tests in these cases to get the - names back consistently or use the `__name__` attribute on data values. + We avoid doing str(value) if dealing with non-trivial values. + The problem is possible different names with different runs, e.g. + different order of dictionary keys (see PYTHONHASHSEED) or dealing + with mock objects. + Trivial scalar values are passed as is. A "trivial" value is a plain scalar, or a tuple or list consisting only of trivial values. - """ - # We avoid doing str(value) if all of the following hold: - # - # * Python version is 2.7.3 or newer (for 2 series) or 3.2.3 or - # newer (for 3 series). Also sys.flags.hash_randomization didn't - # exist before these. - # * sys.flags.hash_randomization is set to True - # * PYTHONHASHSEED is **not** defined in the environment - # * Given `value` argument is not a trivial scalar (None, str, - # int, float). - # - # Trivial scalar values are passed as is in all cases. - - trivial_types = (type(None), bool, str, int, float) - try: - trivial_types += (unicode,) - except NameError: - pass - - def is_trivial(value): - if isinstance(value, trivial_types): - return True - - if isinstance(value, (list, tuple)): - return all(map(is_trivial, value)) - - return False - - if is_hash_randomized() and not is_trivial(value): + if not is_trivial(value): return "{0}_{1}".format(name, index + 1) - try: value = str(value) except UnicodeEncodeError: @@ -145,6 +121,15 @@ def wrapper(self): return func(self, *args, **kwargs) wrapper.__name__ = new_name + # Try to call format on the docstring + if func.__doc__: + try: + wrapper.__doc__ = func.__doc__.format(*args, **kwargs) + except (IndexError, KeyError): + # Maybe the user has added some of the formating strings + # unintentionally in the docstring. Do not raise an exception as it + # could be that he is not aware of the formating feature. + pass return wrapper @@ -182,7 +167,10 @@ elif isinstance(data, list): value = elem test_name = mk_test_name(name, value, i) - add_test(cls, test_name, func, value) + if isinstance(value, dict): + add_test(cls, test_name, func, **value) + else: + add_test(cls, test_name, func, value) def ddt(cls): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.0/test/test_example.py new/ddt-1.0.1/test/test_example.py --- old/ddt-1.0.0/test/test_example.py 2015-01-27 19:35:22.000000000 +0100 +++ new/ddt-1.0.1/test/test_example.py 2015-10-26 18:01:56.000000000 +0100 @@ -31,6 +31,12 @@ a, b = value self.assertGreater(a, b) + @file_data("test_data_dict_dict.json") + def test_file_data_dict_dict(self, start, end, value): + self.assertLess(start, end) + self.assertLess(value, end) + self.assertGreater(value, start) + @file_data('test_data_dict.json') def test_file_data_dict(self, value): self.assertTrue(has_three_elements(value)) @@ -58,3 +64,24 @@ @data(u'ascii', u'non-ascii-\N{SNOWMAN}') def test_unicode(self, value): self.assertIn(value, (u'ascii', u'non-ascii-\N{SNOWMAN}')) + + @data(3, 4, 12, 23) + def test_larger_than_two_with_doc(self, value): + """Larger than two with value {0}""" + self.assertTrue(larger_than_two(value)) + + @data(3, 4, 12, 23) + def test_doc_missing_args(self, value): + """Missing args with value {0} and {1}""" + self.assertTrue(larger_than_two(value)) + + @data(3, 4, 12, 23) + def test_doc_missing_kargs(self, value): + """Missing kargs with value {value} {value2}""" + self.assertTrue(larger_than_two(value)) + + @data([3, 2], [4, 3], [5, 3]) + @unpack + def test_list_extracted_with_doc(self, first_value, second_value): + """Extract into args with first value {} and second value {}""" + self.assertTrue(first_value > second_value) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.0/test/test_functional.py new/ddt-1.0.1/test/test_functional.py --- old/ddt-1.0.0/test/test_functional.py 2015-01-27 19:35:22.000000000 +0100 +++ new/ddt-1.0.1/test/test_functional.py 2015-11-18 23:03:46.000000000 +0100 @@ -3,7 +3,7 @@ import six -from ddt import ddt, data, file_data, is_hash_randomized +from ddt import ddt, data, file_data from nose.tools import assert_equal, assert_is_not_none, assert_raises @@ -226,11 +226,7 @@ assert_is_not_none(getattr(Mytest, 'test_hello_1_ascii')) assert_is_not_none(getattr(Mytest, 'test_hello_2_non_ascii__u2603')) - if is_hash_randomized(): - assert_is_not_none(getattr(Mytest, 'test_hello_3')) - else: - assert_is_not_none(getattr(Mytest, - 'test_hello_3__u__u2603____data__')) + assert_is_not_none(getattr(Mytest, 'test_hello_3')) elif six.PY3: @@ -242,10 +238,21 @@ assert_is_not_none(getattr(Mytest, 'test_hello_1_ascii')) assert_is_not_none(getattr(Mytest, 'test_hello_2_non_ascii__')) - if is_hash_randomized(): - assert_is_not_none(getattr(Mytest, 'test_hello_3')) - else: - assert_is_not_none(getattr(Mytest, 'test_hello_3________data__')) + assert_is_not_none(getattr(Mytest, 'test_hello_3')) + + +def test_ddt_data_object(): + """ + Test not using value if non-trivial arguments + """ + + @ddt + class Mytest(object): + @data(object) + def test_object(self, val): + pass + + assert_is_not_none(getattr(Mytest, 'test_object_1_object')) def test_feed_data_with_invalid_identifier():
