Hello community, here is the log from the commit of package python-ddt for openSUSE:Factory checked in at 2016-09-01 14:03:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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-12-23 09:57:30.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python-ddt.new/python-ddt.changes 2016-09-01 14:03:45.000000000 +0200 @@ -1,0 +2,29 @@ +Thu Sep 1 05:23:40 UTC 2016 - tbechtold@suse.com + +update to version 1.1.0 + * Note explicit support for Python 3.5 + * Catch ImportErrors and improve coverage metrics + * Document the YAML support + * Refactor error functions in process_file_data + * Bump version to 1.1.0 + * Add basic support for YAML data files + * Bump version to 1.0.2 + * Bump version number + * Properly handle file object + * Fix the no-YAML installed test + * Fix Flake8 warnings + * Add more tests for YAML data files + * Split process_file_data into 2 functions + * Remove broken badge 'caniusepython3' + * Variable naming changes + * Flake8: make lambda into 'def' function + * Unconditionally use PyPI mock + * Fix copy-paste error + * Fix unittest with object instance as data + * Add mock to test requirements + * Add PyYAML as a test dependency + * RTD build trigger to use project name + * Load the YAML data safely +- Use pypi.io as Source url + +------------------------------------------------------------------- Old: ---- ddt-1.0.1.tar.gz New: ---- ddt-1.1.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-ddt.spec ++++++ --- /var/tmp/diff_new_pack.8QycSv/_old 2016-09-01 14:03:46.000000000 +0200 +++ /var/tmp/diff_new_pack.8QycSv/_new 2016-09-01 14:03:46.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-ddt # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,13 +17,13 @@ Name: python-ddt -Version: 1.0.1 +Version: 1.1.0 Release: 0 Summary: Data-Driven/Decorated Tests License: MIT Group: Development/Languages/Python Url: https://github.com/txels/ddt -Source: https://pypi.python.org/packages/source/d/ddt/ddt-%{version}.tar.gz +Source: https://pypi.io/packages/source/d/ddt/ddt-%{version}.tar.gz BuildRequires: python-devel BuildRequires: python-setuptools BuildRoot: %{_tmppath}/%{name}-%{version}-build ++++++ ddt-1.0.1.tar.gz -> ddt-1.1.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.1/PKG-INFO new/ddt-1.1.0/PKG-INFO --- old/ddt-1.0.1/PKG-INFO 2015-11-18 23:09:54.000000000 +0100 +++ new/ddt-1.1.0/PKG-INFO 2016-05-31 09:27:22.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: ddt -Version: 1.0.1 +Version: 1.1.0 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/txels/ddt Author: Carles Barrobés @@ -18,4 +18,5 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Software Development :: Testing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.1/ddt.egg-info/PKG-INFO new/ddt-1.1.0/ddt.egg-info/PKG-INFO --- old/ddt-1.0.1/ddt.egg-info/PKG-INFO 2015-11-18 23:09:54.000000000 +0100 +++ new/ddt-1.1.0/ddt.egg-info/PKG-INFO 2016-05-31 09:27:21.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: ddt -Version: 1.0.1 +Version: 1.1.0 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/txels/ddt Author: Carles Barrobés @@ -18,4 +18,5 @@ Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.3 Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 Classifier: Topic :: Software Development :: Testing diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.1/ddt.py new/ddt-1.1.0/ddt.py --- old/ddt-1.0.1/ddt.py 2015-11-18 23:09:00.000000000 +0100 +++ new/ddt-1.1.0/ddt.py 2016-05-31 09:26:35.000000000 +0200 @@ -11,7 +11,14 @@ import re from functools import wraps -__version__ = '1.0.1' +try: + import yaml +except ImportError: # pragma: no cover + _have_yaml = False +else: + _have_yaml = True + +__version__ = '1.1.0' # These attributes will not conflict with any real python attribute # They are added to the decorated test method and processed later @@ -152,25 +159,56 @@ cls_path = os.path.abspath(inspect.getsourcefile(cls)) data_file_path = os.path.join(os.path.dirname(cls_path), file_attr) - def _raise_ve(*args): # pylint: disable-msg=W0613 - raise ValueError("%s does not exist" % file_attr) + def create_error_func(message): # pylint: disable-msg=W0613 + def func(*args): + raise ValueError(message % file_attr) + return func + + # If file does not exist, provide an error function instead + if not os.path.exists(data_file_path): + test_name = mk_test_name(name, "error") + add_test(cls, test_name, create_error_func("%s does not exist"), None) + return + + _is_yaml_file = data_file_path.endswith((".yml", ".yaml")) - if os.path.exists(data_file_path) is False: + # Don't have YAML but want to use YAML file. + if _is_yaml_file and not _have_yaml: test_name = mk_test_name(name, "error") - add_test(cls, test_name, _raise_ve, None) - else: - data = json.loads(open(data_file_path).read()) - for i, elem in enumerate(data): - if isinstance(data, dict): - key, value = elem, data[elem] - test_name = mk_test_name(name, key, i) - elif isinstance(data, list): - value = elem - test_name = mk_test_name(name, value, i) - if isinstance(value, dict): - add_test(cls, test_name, func, **value) - else: - add_test(cls, test_name, func, value) + add_test( + cls, + test_name, + create_error_func("%s is a YAML file, please install PyYAML"), + None + ) + return + + with open(data_file_path) as f: + # Load the data from YAML or JSON + if _is_yaml_file: + data = yaml.safe_load(f) + else: + data = json.load(f) + + _add_tests_from_data(cls, name, func, data) + + +def _add_tests_from_data(cls, name, func, data): + """ + Add tests from data loaded from the data file into the class + + """ + for i, elem in enumerate(data): + if isinstance(data, dict): + key, value = elem, data[elem] + test_name = mk_test_name(name, key, i) + elif isinstance(data, list): + value = elem + test_name = mk_test_name(name, value, i) + 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.1/setup.py new/ddt-1.1.0/setup.py --- old/ddt-1.0.1/setup.py 2015-01-27 19:35:38.000000000 +0100 +++ new/ddt-1.1.0/setup.py 2016-05-25 17:37:37.000000000 +0200 @@ -24,6 +24,7 @@ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Topic :: Software Development :: Testing', ], ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.1/test/test_example.py new/ddt-1.1.0/test/test_example.py --- old/ddt-1.0.1/test/test_example.py 2015-10-26 18:01:56.000000000 +0100 +++ new/ddt-1.1.0/test/test_example.py 2016-05-31 09:26:09.000000000 +0200 @@ -2,6 +2,19 @@ from ddt import ddt, data, file_data, unpack from test.mycode import larger_than_two, has_three_elements, is_a_greeting +try: + import yaml +except ImportError: # pragma: no cover + have_yaml_support = False +else: + have_yaml_support = True + del yaml + +# A good-looking decorator +needs_yaml = unittest.skipUnless( + have_yaml_support, "Need YAML to run this test" +) + class Mylist(list): pass @@ -32,17 +45,34 @@ self.assertGreater(a, b) @file_data("test_data_dict_dict.json") - def test_file_data_dict_dict(self, start, end, value): + def test_file_data_json_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): + def test_file_data_json_dict(self, value): self.assertTrue(has_three_elements(value)) @file_data('test_data_list.json') - def test_file_data_list(self, value): + def test_file_data_json_list(self, value): + self.assertTrue(is_a_greeting(value)) + + @needs_yaml + @file_data("test_data_dict_dict.yaml") + def test_file_data_yaml_dict_dict(self, start, end, value): + self.assertLess(start, end) + self.assertLess(value, end) + self.assertGreater(value, start) + + @needs_yaml + @file_data('test_data_dict.yaml') + def test_file_data_yaml_dict(self, value): + self.assertTrue(has_three_elements(value)) + + @needs_yaml + @file_data('test_data_list.yaml') + def test_file_data_yaml_list(self, value): self.assertTrue(is_a_greeting(value)) @data((3, 2), (4, 3), (5, 3)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ddt-1.0.1/test/test_functional.py new/ddt-1.1.0/test/test_functional.py --- old/ddt-1.0.1/test/test_functional.py 2015-11-18 23:03:46.000000000 +0100 +++ new/ddt-1.1.0/test/test_functional.py 2016-05-31 09:26:09.000000000 +0200 @@ -2,9 +2,14 @@ import json import six +import mock from ddt import ddt, data, file_data -from nose.tools import assert_equal, assert_is_not_none, assert_raises +from nose.tools import ( + assert_true, assert_equal, assert_is_not_none, assert_raises +) + +from test.mycode import has_three_elements @ddt @@ -42,7 +47,7 @@ @ddt -class FileDataMissingDummy(object): +class JSONFileDataMissingDummy(object): """ Dummy class to test the file_data decorator on when JSON file is missing @@ -53,6 +58,18 @@ return value +@ddt +class YAMLFileDataMissingDummy(object): + """ + Dummy class to test the file_data decorator on when + YAML file is missing + """ + + @file_data("test_data_dict_missing.yaml") + def test_something_again(self, value): + return value + + def test_data_decorator(): """ Test the ``data`` method decorator @@ -96,14 +113,15 @@ assert_equal(getattr(data_hello, extra_attr), ("test_data_dict.json",)) -is_test = lambda x: x.startswith('test_') +def _is_test(x): + return x.startswith('test_') def test_ddt(): """ Test the ``ddt`` class decorator """ - tests = len(list(filter(is_test, Dummy.__dict__))) + tests = len(list(filter(_is_test, Dummy.__dict__))) assert_equal(tests, 4) @@ -112,7 +130,7 @@ Test that the ``file_data`` decorator creates two tests """ - tests = len(list(filter(is_test, FileDataDummy.__dict__))) + tests = len(list(filter(_is_test, FileDataDummy.__dict__))) assert_equal(tests, 2) @@ -124,7 +142,7 @@ when it is parsed as a dictionary. """ - tests = set(filter(is_test, FileDataDummy.__dict__)) + tests = set(filter(_is_test, FileDataDummy.__dict__)) tests_dir = os.path.dirname(__file__) test_data_path = os.path.join(tests_dir, 'test_data_dict.json') @@ -141,7 +159,7 @@ """ Test that data is fed to the decorated tests """ - tests = filter(is_test, Dummy.__dict__) + tests = filter(_is_test, Dummy.__dict__) values = [] obj = Dummy() @@ -156,7 +174,7 @@ """ Test that data is fed to the decorated tests from a file """ - tests = filter(is_test, FileDataDummy.__dict__) + tests = filter(_is_test, FileDataDummy.__dict__) values = [] obj = FileDataDummy() @@ -169,11 +187,23 @@ def test_feed_data_file_data_missing_json(): """ - Test that a ValueError is raised + Test that a ValueError is raised when JSON file is missing + """ + tests = filter(_is_test, JSONFileDataMissingDummy.__dict__) + + obj = JSONFileDataMissingDummy() + for test in tests: + method = getattr(obj, test) + assert_raises(ValueError, method) + + +def test_feed_data_file_data_missing_yaml(): + """ + Test that a ValueError is raised when YAML file is missing """ - tests = filter(is_test, FileDataMissingDummy.__dict__) + tests = filter(_is_test, YAMLFileDataMissingDummy.__dict__) - obj = FileDataMissingDummy() + obj = YAMLFileDataMissingDummy() for test in tests: method = getattr(obj, test) assert_raises(ValueError, method) @@ -248,18 +278,18 @@ @ddt class Mytest(object): - @data(object) + @data(object()) def test_object(self, val): pass - assert_is_not_none(getattr(Mytest, 'test_object_1_object')) + assert_is_not_none(getattr(Mytest, 'test_object_1')) def test_feed_data_with_invalid_identifier(): """ Test that data is fed to the decorated tests """ - tests = list(filter(is_test, DummyInvalidIdentifier.__dict__)) + tests = list(filter(_is_test, DummyInvalidIdentifier.__dict__)) assert_equal(len(tests), 1) obj = DummyInvalidIdentifier() @@ -269,3 +299,24 @@ 'test_data_with_invalid_identifier_1_32v2_g__Gmw845h_W_b53wi_' ) assert_equal(method(), '32v2 g #Gmw845h$W b53wi.') + + +@mock.patch('ddt._have_yaml', False) +def test_load_yaml_without_yaml_support(): + """ + Test that YAML files are not loaded if YAML is not installed. + """ + + @ddt + class NoYAMLInstalledTest(object): + + @file_data('test_data_dict.yaml') + def test_file_data_yaml_dict(self, value): + assert_true(has_three_elements(value)) + + tests = filter(_is_test, NoYAMLInstalledTest.__dict__) + + obj = NoYAMLInstalledTest() + for test in tests: + method = getattr(obj, test) + assert_raises(ValueError, method)