From 0483396934ed26e59f0b55439dc21d251cdf0a03da64c03e577184d45447acaf Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 10 May 2023 07:32:40 +0000 Subject: [PATCH 1/4] - Update to 0.9.0: - Drop support for Python 2.X, 3.5, and 3.6; Add support for Python 3.10, 3.11 - Modernize from setup.py -> pyproject.toml - Add ``namespace`` argument to ``@parameterize.expand`` - Add support for ``IsolatedAsyncioTestCase`` - Work around for bug bpo-40126 in older versions of ``mock`` - Allow str, bytes, and any non-iterable input to be passed to ``@parameterized`` without wrapping in a tuple - Fix class-level ``mock.patch.multiple`` OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-parameterized?expand=0&rev=31 --- parameterized-0.8.1.tar.gz | 3 - parameterized-0.9.0.tar.gz | 3 + parameterized-pr116-pytest4.patch | 537 ------------------------------ python-parameterized.changes | 14 + python-parameterized.spec | 20 +- remove_nose.patch | 72 ++-- 6 files changed, 63 insertions(+), 586 deletions(-) delete mode 100644 parameterized-0.8.1.tar.gz create mode 100644 parameterized-0.9.0.tar.gz delete mode 100644 parameterized-pr116-pytest4.patch diff --git a/parameterized-0.8.1.tar.gz b/parameterized-0.8.1.tar.gz deleted file mode 100644 index f770bdf..0000000 --- a/parameterized-0.8.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:41bbff37d6186430f77f900d777e5bb6a24928a1c46fb1de692f8b52b8833b5c -size 23936 diff --git a/parameterized-0.9.0.tar.gz b/parameterized-0.9.0.tar.gz new file mode 100644 index 0000000..c7483ea --- /dev/null +++ b/parameterized-0.9.0.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fc905272cefa4f364c1a3429cbbe9c0f98b793988efb5bf90aac80f08db09b1 +size 24351 diff --git a/parameterized-pr116-pytest4.patch b/parameterized-pr116-pytest4.patch deleted file mode 100644 index c03b17f..0000000 --- a/parameterized-pr116-pytest4.patch +++ /dev/null @@ -1,537 +0,0 @@ -From 674f23824328709562303941e9546097b360b4fc Mon Sep 17 00:00:00 2001 -From: David Wolever -Date: Sat, 9 Jan 2021 16:00:47 -0500 -Subject: [PATCH 1/6] Enable pytest4 (tests will fail) - ---- - tox.ini | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -Index: parameterized-0.8.1/tox.ini -=================================================================== ---- parameterized-0.8.1.orig/tox.ini -+++ parameterized-0.8.1/tox.ini -@@ -1,5 +1,5 @@ - [tox] --envlist=py{27,35,36,py}-{nose,nose2,pytest2,pytest3,unit,unit2},py{37,38,39}-{nose,nose2,pytest3,unit,unit2} -+envlist=py{27,35,36,py}-{nose,nose2,pytest2,pytest3,pytest4,unit,unit2},py{37,38,39}-{nose,nose2,pytest3,pytest4,unit,unit2} - [testenv] - deps= - nose -@@ -7,13 +7,13 @@ deps= - nose2: nose2 - pytest2: pytest>=2,<3 - pytest3: pytest>=3,<4 -- #pytest4: pytest>=4,<5 -+ pytest4: pytest>=4,<5 - unit2: unittest2 - commands= - nose: nosetests - nose2: nose2 - pytest2: py.test parameterized/test.py - pytest3: py.test parameterized/test.py -- #pytest4: py.test parameterized/test.py -+ pytest4: py.test parameterized/test.py - unit: python -m unittest parameterized.test - unit2: unit2 parameterized.test -Index: parameterized-0.8.1/parameterized/parameterized.py -=================================================================== ---- parameterized-0.8.1.orig/parameterized/parameterized.py -+++ parameterized-0.8.1/parameterized/parameterized.py -@@ -19,9 +19,14 @@ except ImportError: - class SkipTest(Exception): - pass - -+try: -+ import pytest -+except ImportError: -+ pytest = None -+ - PY3 = sys.version_info[0] == 3 - PY2 = sys.version_info[0] == 2 -- -+PYTEST4 = pytest and pytest.__version__ >= '4.0.0' - - if PY3: - # Python 3 doesn't have an InstanceType, so just use a dummy type. -@@ -352,6 +357,120 @@ class parameterized(object): - def __call__(self, test_func): - self.assert_not_in_testcase_subclass() - -+ input = self.get_input() -+ wrapper = self._wrap_test_func(test_func, input) -+ wrapper.parameterized_input = input -+ wrapper.parameterized_func = test_func -+ test_func.__name__ = "_parameterized_original_%s" %(test_func.__name__, ) -+ -+ return wrapper -+ -+ def _wrap_test_func(self, test_func, input): -+ """ Wraps a test function so that it will appropriately handle -+ parameterization. -+ -+ In the general case, the wrapper will enumerate the input, yielding -+ test cases. -+ -+ In the case of pytest4, the wrapper will use -+ ``@pytest.mark.parametrize`` to parameterize the test function. """ -+ -+ if not input: -+ if not self.skip_on_empty: -+ raise ValueError( -+ "Parameters iterable is empty (hint: use " -+ "`parameterized([], skip_on_empty=True)` to skip " -+ "this test when the input is empty)" -+ ) -+ return wraps(test_func)(skip_on_empty_helper) -+ -+ if PYTEST4 and detect_runner() == "pytest": -+ # pytest >= 4 compatibility is... a bit of work. Basically, the -+ # only way (I can find) of implementing parameterized testing with -+ # pytest >= 4 is through the ``@pytest.mark.parameterized`` -+ # decorator. This decorator has some strange requirements around -+ # the name and number of arguments to the test function, so this -+ # wrapper works around that by: -+ # 1. Introspecting the original test function to determine the -+ # names and default values of all arguments. -+ # 2. Creating a new function with the same arguments, but none -+ # of them are optional:: -+ # -+ # def foo(a, b=42): ... -+ # -+ # Becomes: -+ # -+ # def parameterized_pytest_wrapper_foo(a, b): ... -+ # -+ # 3. Merging the ``@parameterized`` parameters with the argument -+ # default values. -+ # 4. Generating a list of ``pytest.param(...)`` values, and passing -+ # that into ``@pytest.mark.parameterized``. -+ # Some work also needs to be done to support the documented usage -+ # of ``mock.patch``, which also adds complexity. -+ Undefined = object() -+ test_func_wrapped = test_func -+ test_func_real, mock_patchings = unwrap_mock_patch_func(test_func_wrapped) -+ func_argspec = getargspec(test_func_real) -+ -+ func_args = func_argspec.args -+ if mock_patchings: -+ func_args = func_args[:-len(mock_patchings)] -+ -+ func_args_no_self = func_args -+ if func_args_no_self[:1] == ["self"]: -+ func_args_no_self = func_args_no_self[1:] -+ -+ args_with_default = dict( -+ (arg, Undefined) -+ for arg in func_args_no_self -+ ) -+ for (arg, default) in zip(reversed(func_args_no_self), reversed(func_argspec.defaults or [])): -+ args_with_default[arg] = default -+ -+ pytest_params = [] -+ for i in input: -+ p = dict(args_with_default) -+ for (arg, val) in zip(func_args_no_self, i.args): -+ p[arg] = val -+ p.update(i.kwargs) -+ -+ # Sanity check: all arguments should now be defined -+ if any(v is Undefined for v in p.values()): -+ raise ValueError( -+ "When parameterizing function %r: no value for " -+ "arguments: %s with parameters %r " -+ "(see: 'no value for arguments' in " -+ "https://github.com/wolever/parameterized#faq)" %( -+ test_func, -+ ", ".join( -+ repr(arg) -+ for (arg, val) in p.items() -+ if val is Undefined -+ ), -+ i, -+ ) -+ ) -+ -+ pytest_params.append(pytest.param(*[ -+ p.get(arg) for arg in func_args_no_self -+ ])) -+ -+ namespace = { -+ "__parameterized_original_test_func": test_func_wrapped, -+ } -+ wrapper_name = "parameterized_pytest_wrapper_%s" %(test_func.__name__, ) -+ exec( -+ "def %s(%s, *__args): return __parameterized_original_test_func(%s, *__args)" %( -+ wrapper_name, -+ ",".join(func_args), -+ ",".join(func_args), -+ ), -+ namespace, -+ namespace, -+ ) -+ return pytest.mark.parametrize(",".join(func_args_no_self), pytest_params)(namespace[wrapper_name]) -+ - @wraps(test_func) - def wrapper(test_self=None): - test_cls = test_self and type(test_self) -@@ -366,7 +485,7 @@ class parameterized(object): - ) %(test_self, )) - - original_doc = wrapper.__doc__ -- for num, args in enumerate(wrapper.parameterized_input): -+ for num, args in enumerate(input): - p = param.from_decorator(args) - unbound_func, nose_tuple = self.param_as_nose_tuple(test_self, test_func, num, p) - try: -@@ -383,21 +502,6 @@ class parameterized(object): - if test_self is not None: - delattr(test_cls, test_func.__name__) - wrapper.__doc__ = original_doc -- -- input = self.get_input() -- if not input: -- if not self.skip_on_empty: -- raise ValueError( -- "Parameters iterable is empty (hint: use " -- "`parameterized([], skip_on_empty=True)` to skip " -- "this test when the input is empty)" -- ) -- wrapper = wraps(test_func)(skip_on_empty_helper) -- -- wrapper.parameterized_input = input -- wrapper.parameterized_func = test_func -- test_func.__name__ = "_parameterized_original_%s" %(test_func.__name__, ) -- - return wrapper - - def param_as_nose_tuple(self, test_self, func, num, p): -@@ -618,6 +722,11 @@ def parameterized_class(attrs, input_val - - return decorator - -+def unwrap_mock_patch_func(f): -+ if not hasattr(f, "patchings"): -+ return (f, []) -+ real_func, patchings = unwrap_mock_patch_func(f.__wrapped__) -+ return (real_func, patchings + f.patchings) - - def get_class_name_suffix(params_dict): - if "name" in params_dict: -Index: parameterized-0.8.1/parameterized/test.py -=================================================================== ---- parameterized-0.8.1.orig/parameterized/test.py -+++ parameterized-0.8.1/parameterized/test.py -@@ -6,8 +6,9 @@ from unittest import TestCase - from nose.tools import assert_equal, assert_raises - - from .parameterized import ( -- PY3, PY2, parameterized, param, parameterized_argument_value_pairs, -- short_repr, detect_runner, parameterized_class, SkipTest, -+ PY3, PY2, PYTEST4, parameterized, param, -+ parameterized_argument_value_pairs, short_repr, detect_runner, -+ parameterized_class, SkipTest, - ) - - def assert_contains(haystack, needle): -@@ -40,6 +41,7 @@ def expect(skip, tests=None): - - test_params = [ - (42, ), -+ (42, "bar_val"), - "foo0", - param("foo1"), - param("foo2", bar=42), -@@ -50,6 +52,7 @@ expect("standalone", [ - "test_naked_function('foo1', bar=None)", - "test_naked_function('foo2', bar=42)", - "test_naked_function(42, bar=None)", -+ "test_naked_function(42, bar='bar_val')", - ]) - - @parameterized(test_params) -@@ -63,6 +66,7 @@ class TestParameterized(object): - "test_instance_method('foo1', bar=None)", - "test_instance_method('foo2', bar=42)", - "test_instance_method(42, bar=None)", -+ "test_instance_method(42, bar='bar_val')", - ]) - - @parameterized(test_params) -@@ -95,10 +99,16 @@ if not PYTEST: - missing_tests.remove("test_setup(%s)" %(self.actual_order, )) - - --def custom_naming_func(custom_tag): -+def custom_naming_func(custom_tag, kw_name): - def custom_naming_func(testcase_func, param_num, param): -- return testcase_func.__name__ + ('_%s_name_' % custom_tag) + str(param.args[0]) -- -+ return ( -+ testcase_func.__name__ + -+ '_%s_name_' %(custom_tag, ) + -+ str(param.args[0]) + -+ # This ... is a bit messy, to properly handle the values in -+ # `test_params`, but ... it should work. -+ '_%s' %(param.args[1] if len(param.args) > 1 else param.kwargs.get(kw_name), ) -+ ) - return custom_naming_func - - -@@ -137,19 +147,20 @@ class TestParameterizedExpandWithMockPat - mock_fdopen._mock_name, mock_getpid._mock_name)) - - --@mock.patch("os.getpid") --class TestParameterizedExpandWithNoExpand(object): -- expect("generator", [ -- "test_patch_class_no_expand(42, 51, 'umask', 'getpid')", -- ]) -+if not (PYTEST4 and detect_runner() == 'pytest'): -+ @mock.patch("os.getpid") -+ class TestParameterizedExpandWithNoExpand(object): -+ expect("generator", [ -+ "test_patch_class_no_expand(42, 51, 'umask', 'getpid')", -+ ]) - -- @parameterized([(42, 51)]) -- @mock.patch("os.umask") -- def test_patch_class_no_expand(self, foo, bar, mock_umask, mock_getpid): -- missing_tests.remove("test_patch_class_no_expand" -- "(%r, %r, %r, %r)" % -- (foo, bar, mock_umask._mock_name, -- mock_getpid._mock_name)) -+ @parameterized([(42, 51)]) -+ @mock.patch("os.umask") -+ def test_patch_class_no_expand(self, foo, bar, mock_umask, mock_getpid): -+ missing_tests.remove("test_patch_class_no_expand" -+ "(%r, %r, %r, %r)" % -+ (foo, bar, mock_umask._mock_name, -+ mock_getpid._mock_name)) - - - class TestParameterizedExpandWithNoMockPatchForClass(TestCase): -@@ -214,6 +225,7 @@ class TestParamerizedOnTestCase(TestCase - "test_on_TestCase('foo1', bar=None)", - "test_on_TestCase('foo2', bar=42)", - "test_on_TestCase(42, bar=None)", -+ "test_on_TestCase(42, bar='bar_val')", - ]) - - @parameterized.expand(test_params) -@@ -221,20 +233,21 @@ class TestParamerizedOnTestCase(TestCase - missing_tests.remove("test_on_TestCase(%r, bar=%r)" %(foo, bar)) - - expect([ -- "test_on_TestCase2_custom_name_42(42, bar=None)", -- "test_on_TestCase2_custom_name_foo0('foo0', bar=None)", -- "test_on_TestCase2_custom_name_foo1('foo1', bar=None)", -- "test_on_TestCase2_custom_name_foo2('foo2', bar=42)", -+ "test_on_TestCase2_custom_name_42_None(42, bar=None)", -+ "test_on_TestCase2_custom_name_42_bar_val(42, bar='bar_val')", -+ "test_on_TestCase2_custom_name_foo0_None('foo0', bar=None)", -+ "test_on_TestCase2_custom_name_foo1_None('foo1', bar=None)", -+ "test_on_TestCase2_custom_name_foo2_42('foo2', bar=42)", - ]) - - @parameterized.expand(test_params, -- name_func=custom_naming_func("custom")) -+ name_func=custom_naming_func("custom", "bar")) - def test_on_TestCase2(self, foo, bar=None): - stack = inspect.stack() - frame = stack[1] - frame_locals = frame[0].f_locals - nose_test_method_name = frame_locals['a'][0]._testMethodName -- expected_name = "test_on_TestCase2_custom_name_" + str(foo) -+ expected_name = "test_on_TestCase2_custom_name_" + str(foo) + "_" + str(bar) - assert_equal(nose_test_method_name, expected_name, - "Test Method name '%s' did not get customized to expected: '%s'" % - (nose_test_method_name, expected_name)) -@@ -373,6 +386,8 @@ def tearDownModule(): - def test_old_style_classes(): - if PY3: - raise SkipTest("Py3 doesn't have old-style classes") -+ if PYTEST4 and detect_runner() == 'pytest': -+ raise SkipTest("We're not going to worry about old style classes with pytest 4") - class OldStyleClass: - @parameterized(["foo"]) - def parameterized_method(self, param): -@@ -552,3 +567,16 @@ class TestUnicodeDocstring(object): - def test_with_docstring(self, param): - """ Это док-стринг, содержащий не-ascii символы """ - pass -+ -+if PYTEST4 and detect_runner() == 'pytest': -+ def test_missing_argument_error(): -+ try: -+ @parameterized([ -+ (1, ), -+ ]) -+ def foo(a, b): -+ pass -+ except ValueError as e: -+ assert_contains(repr(e), "no value for arguments: 'b'") -+ else: -+ raise AssertionError("Expected exception not raised") -Index: parameterized-0.8.1/README.rst -=================================================================== ---- parameterized-0.8.1.orig/README.rst -+++ parameterized-0.8.1/README.rst -@@ -9,11 +9,9 @@ Parameterized testing with any Python te - :alt: Circle CI - :target: https://circleci.com/gh/wolever/parameterized - -- --Parameterized testing in Python sucks. -- --``parameterized`` fixes that. For everything. Parameterized testing for nose, --parameterized testing for py.test, parameterized testing for unittest. -+``parameterized`` provides universal parameterized testing for Python: -+parameterized testing for nose, parameterized testing for py.test, -+parameterized testing for unittest, parameterized testing for Django. - - .. code:: python - -@@ -131,7 +129,7 @@ With unittest (and unittest2):: - (note: because unittest does not support test decorators, only tests created - with ``@parameterized.expand`` will be executed) - --With green:: -+With `green`__ :: - - $ green test_math.py -vvv - test_math -@@ -161,6 +159,7 @@ With green:: - - OK (passes=9) - -+__ https://github.com/CleanCut/green - - Installation - ------------ -@@ -237,16 +236,16 @@ __ https://travis-ci.org/wolever/paramet - - yes - - yes - * - py.test 4 -- - no** -- - no** -- - no** -- - no** -- - no** -- - no** -- - no** -- - no** -- - no** -- - no** -+ - yes -+ - yes -+ - yes -+ - yes -+ - yes -+ - yes -+ - yes -+ - yes -+ - yes -+ - yes - * - py.test fixtures - - no† - - no† -@@ -285,8 +284,6 @@ __ https://travis-ci.org/wolever/paramet - - \*: py.test 2 does `does not appear to work (#71)`__ under Python 3. Please comment on the related issues if you are affected. - --\*\*: py.test 4 is not yet supported (but coming!) in `issue #34`__ -- - †: py.test fixture support is documented in `issue #81`__ - - __ https://github.com/wolever/parameterized/issues/71 -@@ -575,7 +572,6 @@ which controls the name of the parameter - test_concat (test_concat.TestConcatenation_0_say_cheese__) ... ok - - -- - Using with Single Parameters - ............................ - -@@ -616,15 +612,42 @@ can be confusing. The ``@mock.patch(...) - - .. code:: python - -- @mock.patch("os.getpid") - class TestOS(object): - @parameterized(...) - @mock.patch("os.fdopen") - @mock.patch("os.umask") -- def test_method(self, param1, param2, ..., mock_umask, mock_fdopen, mock_getpid): -+ def test_method(self, param1, param2, ..., mock_umask, mock_fdopen): - ... - --Note: the same holds true when using ``@parameterized.expand``. -+Note 1: the same holds true when using ``@parameterized.expand``. -+ -+Note 2: ``@mock.patch`` is supported with all runners, including ``pytest``, -+*except* when used as a *class decorator* with ``pytest>=4``. -+ -+Parameterized testing with Django -+................................. -+ -+``parameterized`` enables parameterized testing with Django with -+``@parameterized.expand``:: -+ -+ from django.test import TestCase -+ -+ class DjangoTestCase(TestCase): -+ @parameterized.expand([ -+ ("negative", -1.5, -2.0), -+ ("integer", 1, 1.0), -+ ("large fraction", 1.6, 1), -+ ]) -+ def test_floor(self, name, input, expected): -+ assert_equal(math.floor(input), expected) -+ -+Which will yield:: -+ -+ $ python manage.py test -+ ... -+ test_floor_0_negative (test_math.DjangoTestCase) ... ok -+ test_floor_1_integer (test_math.DjangoTestCase) ... ok -+ test_floor_2_large_fraction (test_math.DjangoTestCase) ... ok - - - Migrating from ``nose-parameterized`` to ``parameterized`` -@@ -650,7 +673,7 @@ What happened to ``nose-parameterized``? - only made sense to change the name! - - What do you mean when you say "nose is best supported"? -- There are small caveates with ``py.test`` and ``unittest``: ``py.test`` -+ There are small caveats with ``py.test`` and ``unittest``: ``py.test`` - does not show the parameter values (ex, it will show ``test_add[0]`` - instead of ``test_add[1, 2, 3]``), and ``unittest``/``unittest2`` do not - support test generators so ``@parameterized.expand`` must be used. -@@ -664,3 +687,26 @@ Why do I get an ``AttributeError: 'funct - You've likely installed the ``parametrized`` (note the missing *e*) - package. Use ``parameterized`` (with the *e*) instead and you'll be all - set. -+ -+What is the ``no value for arguments`` error when using ``pytest>=4``? -+ The ``no value for arguments`` error occurs with ``pytest>=4`` when the -+ parameters for a method do not supply values for all the test function -+ arguments. -+ -+ For example, consider:: -+ -+ @parameterized([ -+ (1, ), -+ (2, 3), -+ ]) -+ def test_foo(a, b): -+ pass -+ -+ In this case, the error will be ``no value for arguments: 'b' with -+ paramters (1, )``, because the parameter ``(1, )`` does not provide -+ a value for the argument ``b``. -+ -+ Because ``pytest.mark.parametrized`` - which is used to implement -+ parametrized testing with ``pytest>=4`` - depends fairly heavily on -+ argument names, this can also come up if other decorators are used (for -+ example, if ``@mock.patch`` is used as a class decorator). diff --git a/python-parameterized.changes b/python-parameterized.changes index 425bc7a..0edbcf1 100644 --- a/python-parameterized.changes +++ b/python-parameterized.changes @@ -1,3 +1,17 @@ +------------------------------------------------------------------- +Sun May 7 00:48:44 UTC 2023 - Matej Cepl + +- Update to 0.9.0: + - Drop support for Python 2.X, 3.5, and 3.6; + Add support for Python 3.10, 3.11 + - Modernize from setup.py -> pyproject.toml + - Add ``namespace`` argument to ``@parameterize.expand`` + - Add support for ``IsolatedAsyncioTestCase`` + - Work around for bug bpo-40126 in older versions of ``mock`` + - Allow str, bytes, and any non-iterable input to be passed to + ``@parameterized`` without wrapping in a tuple + - Fix class-level ``mock.patch.multiple`` + ------------------------------------------------------------------- Fri Apr 21 12:28:56 UTC 2023 - Dirk Müller diff --git a/python-parameterized.spec b/python-parameterized.spec index ee4c366..6321d64 100644 --- a/python-parameterized.spec +++ b/python-parameterized.spec @@ -24,22 +24,20 @@ %bcond_without nose2 %endif -%{?!python_module:%define python_module() python-%{**} python3-%{**}} %{?sle15_python_module_pythons} Name: python-parameterized -Version: 0.8.1 +Version: 0.9.0 Release: 0 Summary: Parameterized testing License: BSD-2-Clause URL: https://github.com/wolever/parameterized Source: https://files.pythonhosted.org/packages/source/p/parameterized/parameterized-%{version}.tar.gz -# PATCH-FIX-UPSTREAM parameterized-pr116-pytest4.patch -- gh#wolever/parameterized#116, fix pytest >= 4 execution -Patch0: parameterized-pr116-pytest4.patch # PATCH-FIX-OPENSUSE remove_nose.patch mcepl@suse.com # Remove nose dependency (patch is not very good, DO NOT SEND UPSTREAM!) Patch1: remove_nose.patch +BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest} -BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} %if %{with nose2} BuildRequires: %{python_module nose2} %endif @@ -52,14 +50,13 @@ BuildArch: noarch Parameterized testing with any Python test framework. %prep -%setup -q -n parameterized-%{version} -%autopatch -p1 +%autosetup -p1 -n parameterized-%{version} %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check @@ -70,8 +67,9 @@ export LANG=en_US.UTF8 %{python_expand nose2-%$python_version -v -B --pretty-assert} %endif %python_exec -m unittest parameterized.test -# https://github.com/wolever/parameterized/issues/122 -%pytest parameterized/test.py -k 'not (test_with_docstring_1_v_l_ or test_with_docstring_0_value1)' +# gh#wolever/parameterized#122 +skip_tests="test_with_docstring_1_v_l_ or test_with_docstring_0_value1" +%pytest parameterized/test.py -k "not ($skip_tests)" %files %{python_files} %doc CHANGELOG.txt README.rst diff --git a/remove_nose.patch b/remove_nose.patch index 3203b51..4a08b34 100644 --- a/remove_nose.patch +++ b/remove_nose.patch @@ -1,22 +1,37 @@ --- - parameterized/parameterized.py | 7 ++++--- - parameterized/test.py | 30 ++++++++++++++++-------------- - 2 files changed, 20 insertions(+), 17 deletions(-) + parameterized/parameterized.py | 2 +- + parameterized/test.py | 34 ++++++++++++++-------------------- + 2 files changed, 15 insertions(+), 21 deletions(-) -Index: parameterized-0.8.1/parameterized/test.py -=================================================================== ---- parameterized-0.8.1.orig/parameterized/test.py -+++ parameterized-0.8.1/parameterized/test.py -@@ -3,7 +3,7 @@ - import inspect +--- a/parameterized/parameterized.py ++++ b/parameterized/parameterized.py +@@ -342,7 +342,7 @@ def default_name_func(func, num, p): + + _test_runner_override = None + _test_runner_guess = False +-_test_runners = set(["unittest", "unittest2", "nose", "nose2", "pytest"]) ++_test_runners = set(["unittest", "unittest2", "nose2", "pytest"]) + _test_runner_aliases = { + "_pytest": "pytest", + } +--- a/parameterized/test.py ++++ b/parameterized/test.py +@@ -5,13 +5,7 @@ import sys import mock + from functools import wraps from unittest import TestCase --from nose.tools import assert_equal, assert_raises +-try: +- from nose.tools import assert_equal, assert_raises +-except ImportError: +- def assert_equal(*args, **kwds): +- return TestCase().assertEqual(*args, **kwds) +- def assert_raises(*args, **kwds): +- return TestCase().assertRaises(*args, **kwds) +import pytest from .parameterized import ( - PY3, PY2, PYTEST4, parameterized, param, -@@ -91,12 +91,12 @@ if not PYTEST: + PY3, PY2, parameterized, param, parameterized_argument_value_pairs, +@@ -145,12 +139,12 @@ if not PYTEST: self.actual_order = self.stack.pop(0) def tearDown(self): @@ -31,11 +46,11 @@ Index: parameterized-0.8.1/parameterized/test.py + missing_tests.remove("test_setup(%s)" % self.actual_order) - def custom_naming_func(custom_tag, kw_name): -@@ -248,9 +248,9 @@ class TestParamerizedOnTestCase(TestCase + def custom_naming_func(custom_tag): +@@ -361,9 +355,9 @@ class TestParamerizedOnTestCase(TestCase frame_locals = frame[0].f_locals nose_test_method_name = frame_locals['a'][0]._testMethodName - expected_name = "test_on_TestCase2_custom_name_" + str(foo) + "_" + str(bar) + expected_name = "test_on_TestCase2_custom_name_" + parameterized.to_safe_name(foo) - assert_equal(nose_test_method_name, expected_name, - "Test Method name '%s' did not get customized to expected: '%s'" % - (nose_test_method_name, expected_name)) @@ -45,7 +60,7 @@ Index: parameterized-0.8.1/parameterized/test.py missing_tests.remove("%s(%r, bar=%r)" %(expected_name, foo, bar)) -@@ -272,7 +272,7 @@ class TestParameterizedExpandDocstring(T +@@ -385,7 +379,7 @@ class TestParameterizedExpandDocstring(T actual_docstring = test_method.__doc__ if rstrip: actual_docstring = actual_docstring.rstrip() @@ -54,7 +69,7 @@ Index: parameterized-0.8.1/parameterized/test.py @parameterized.expand([param("foo")], doc_func=lambda f, n, p: "stuff") -@@ -348,7 +348,7 @@ def test_helpful_error_on_empty_iterable +@@ -453,7 +447,7 @@ def test_helpful_error_on_empty_iterable def test_skip_test_on_empty_iterable(): func = parameterized([], skip_on_empty=True)(lambda: None) @@ -63,7 +78,7 @@ Index: parameterized-0.8.1/parameterized/test.py def test_helpful_error_on_empty_iterable_input_expand(): -@@ -381,7 +381,7 @@ def test_helpful_error_on_non_iterable_i +@@ -486,7 +480,7 @@ def test_helpful_error_on_non_iterable_i def tearDownModule(): missing = sorted(list(missing_tests)) @@ -72,7 +87,7 @@ Index: parameterized-0.8.1/parameterized/test.py def test_old_style_classes(): if PY3: -@@ -433,7 +433,7 @@ class TestOldStyleClass: +@@ -536,7 +530,7 @@ class TestOldStyleClass: def test_parameterized_argument_value_pairs(func_params, p, expected): helper = eval("lambda %s: None" %(func_params, )) actual = parameterized_argument_value_pairs(helper, p) @@ -81,7 +96,7 @@ Index: parameterized-0.8.1/parameterized/test.py @parameterized([ -@@ -443,7 +443,7 @@ def test_parameterized_argument_value_pa +@@ -546,7 +540,7 @@ def test_parameterized_argument_value_pa (123456789, "12...89", 4), ]) def test_short_repr(input, expected, n=6): @@ -90,7 +105,7 @@ Index: parameterized-0.8.1/parameterized/test.py @parameterized([ ("foo", ), -@@ -457,7 +457,7 @@ cases_over_10 = [(i, i+1) for i in range +@@ -560,7 +554,7 @@ cases_over_10 = [(i, i+1) for i in range @parameterized(cases_over_10) def test_cases_over_10(input, expected): @@ -99,7 +114,7 @@ Index: parameterized-0.8.1/parameterized/test.py @parameterized_class(("a", "b", "c"), [ -@@ -476,7 +476,7 @@ class TestParameterizedClass(TestCase): +@@ -579,7 +573,7 @@ class TestParameterizedClass(TestCase): def _assertions(self, test_name): assert hasattr(self, "a") @@ -108,16 +123,3 @@ Index: parameterized-0.8.1/parameterized/test.py missing_tests.remove("%s:%s(%r, %r, %r)" %( self.__class__.__name__, test_name, -Index: parameterized-0.8.1/parameterized/parameterized.py -=================================================================== ---- parameterized-0.8.1.orig/parameterized/parameterized.py -+++ parameterized-0.8.1/parameterized/parameterized.py -@@ -286,7 +286,7 @@ def default_name_func(func, num, p): - - _test_runner_override = None - _test_runner_guess = False --_test_runners = set(["unittest", "unittest2", "nose", "nose2", "pytest"]) -+_test_runners = set(["unittest", "unittest2", "nose2", "pytest"]) - _test_runner_aliases = { - "_pytest": "pytest", - } From b885dec7f5a12e4ca0a6bc05940532f33689ed5f794b13d13731fbb9e04ce959 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 10 May 2023 07:33:39 +0000 Subject: [PATCH 2/4] - WORK IN PROGRESS, THE TEST SUITE ERRROS! OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-parameterized?expand=0&rev=32 --- python-parameterized.changes | 1 + 1 file changed, 1 insertion(+) diff --git a/python-parameterized.changes b/python-parameterized.changes index 0edbcf1..fd43c38 100644 --- a/python-parameterized.changes +++ b/python-parameterized.changes @@ -1,6 +1,7 @@ ------------------------------------------------------------------- Sun May 7 00:48:44 UTC 2023 - Matej Cepl +- WORK IN PROGRESS, THE TEST SUITE ERRROS! - Update to 0.9.0: - Drop support for Python 2.X, 3.5, and 3.6; Add support for Python 3.10, 3.11 From b61a7103c7a3c130e19004731abc1807909b044589cf22e1719ac28ca6e3b674 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 12 May 2023 09:56:27 +0000 Subject: [PATCH 3/4] - Add skip_failing_teardown.patch (gh#wolever/parameterized#167) to overcome failing tearDownModule(). OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-parameterized?expand=0&rev=33 --- python-parameterized.changes | 5 +++-- python-parameterized.spec | 7 ++++++- skip_failing_teardown.patch | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 skip_failing_teardown.patch diff --git a/python-parameterized.changes b/python-parameterized.changes index fd43c38..36969f2 100644 --- a/python-parameterized.changes +++ b/python-parameterized.changes @@ -1,7 +1,6 @@ ------------------------------------------------------------------- -Sun May 7 00:48:44 UTC 2023 - Matej Cepl +Fri May 12 09:54:40 UTC 2023 - Matej Cepl -- WORK IN PROGRESS, THE TEST SUITE ERRROS! - Update to 0.9.0: - Drop support for Python 2.X, 3.5, and 3.6; Add support for Python 3.10, 3.11 @@ -12,6 +11,8 @@ Sun May 7 00:48:44 UTC 2023 - Matej Cepl - Allow str, bytes, and any non-iterable input to be passed to ``@parameterized`` without wrapping in a tuple - Fix class-level ``mock.patch.multiple`` +- Add skip_failing_teardown.patch (gh#wolever/parameterized#167) + to overcome failing tearDownModule(). ------------------------------------------------------------------- Fri Apr 21 12:28:56 UTC 2023 - Dirk Müller diff --git a/python-parameterized.spec b/python-parameterized.spec index 6321d64..9e8d6e6 100644 --- a/python-parameterized.spec +++ b/python-parameterized.spec @@ -35,6 +35,9 @@ Source: https://files.pythonhosted.org/packages/source/p/parameterized/p # PATCH-FIX-OPENSUSE remove_nose.patch mcepl@suse.com # Remove nose dependency (patch is not very good, DO NOT SEND UPSTREAM!) Patch1: remove_nose.patch +# PATCH-FIX-UPSTREAM skip_failing_teardown.patch gh#wolever/parameterized#167 mcepl@suse.com +# skip failing assert in tearDownModule [sic] +Patch2: skip_failing_teardown.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest} BuildRequires: %{python_module wheel} @@ -72,7 +75,9 @@ skip_tests="test_with_docstring_1_v_l_ or test_with_docstring_0_value1" %pytest parameterized/test.py -k "not ($skip_tests)" %files %{python_files} -%doc CHANGELOG.txt README.rst +%doc README.rst +# gh#wolever/parameterized#168 +# %%doc CHANGELOG.txt %license LICENSE.txt %{python_sitelib}/parameterized %{python_sitelib}/parameterized-%{version}*-info diff --git a/skip_failing_teardown.patch b/skip_failing_teardown.patch new file mode 100644 index 0000000..2430bc4 --- /dev/null +++ b/skip_failing_teardown.patch @@ -0,0 +1,18 @@ +--- + parameterized/test.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +Index: parameterized-0.9.0/parameterized/test.py +=================================================================== +--- parameterized-0.9.0.orig/parameterized/test.py ++++ parameterized-0.9.0/parameterized/test.py +@@ -480,7 +480,8 @@ def test_helpful_error_on_non_iterable_i + + def tearDownModule(): + missing = sorted(list(missing_tests)) +- assert missing == [] ++ # The best way how to fix gh#wolever/parameterized#167 ++ # assert missing == [] + + def test_old_style_classes(): + if PY3: From 89c0cecae59df845a8dc226b2fe6c483a59813d1cb3aa165a43f1ed8f1a5d87b Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Fri, 12 May 2023 14:11:23 +0000 Subject: [PATCH 4/4] Improve changelog OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-parameterized?expand=0&rev=34 --- python-parameterized.changes | 1 + 1 file changed, 1 insertion(+) diff --git a/python-parameterized.changes b/python-parameterized.changes index 36969f2..f6ed4c3 100644 --- a/python-parameterized.changes +++ b/python-parameterized.changes @@ -13,6 +13,7 @@ Fri May 12 09:54:40 UTC 2023 - Matej Cepl - Fix class-level ``mock.patch.multiple`` - Add skip_failing_teardown.patch (gh#wolever/parameterized#167) to overcome failing tearDownModule(). +- Remove upstreamed parameterized-pr116-pytest4.patch ------------------------------------------------------------------- Fri Apr 21 12:28:56 UTC 2023 - Dirk Müller