yaql: add patch to drop unittest2 dependency

in SUSE the implicit unittest2 dependency of python was patched
out to prepare for python 3.9, so we need to remove its uses
via a patch

Change-Id: Ida3381f4715cf28d403fe683b63188aa09fa0608
This commit is contained in:
Dirk Mueller 2021-02-16 10:31:36 +01:00
parent 3a09516b12
commit 8b90b1b6e4
2 changed files with 269 additions and 0 deletions

View File

@ -0,0 +1,267 @@
From 0b006f07226138ef26ab8296494f1dc1c09908e2 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Thu, 11 Jun 2020 11:55:14 +0200
Subject: [PATCH] Replace assertItemsEqual with assertCountEqual
assertItemsEqual was removed from Python's unittest.TestCase in
Python 3.3 [1][2]. We have been able to use them since then, because
testtools required unittest2, which still included it. With testtools
removing Python 2.7 support [3][4], we will lose support for
assertItemsEqual, so we should switch to use assertCountEqual.
[1] - https://bugs.python.org/issue17866
[2] - https://hg.python.org/cpython/rev/d9921cb6e3cd
[3] - testing-cabal/testtools#286
[4] - testing-cabal/testtools#277
Change-Id: I1591e8603262d377d8e0801af152928787374e79
---
yaql/tests/test_collections.py | 44 +++++++++++++++++-----------------
yaql/tests/test_contexts.py | 6 ++---
yaql/tests/test_legacy.py | 2 +-
yaql/tests/test_queries.py | 20 ++++++++--------
4 files changed, 36 insertions(+), 36 deletions(-)
Index: yaql-1.1.3/yaql/tests/test_collections.py
===================================================================
--- yaql-1.1.3.orig/yaql/tests/test_collections.py
+++ yaql-1.1.3/yaql/tests/test_collections.py
@@ -177,15 +177,15 @@ class TestCollections(yaql.tests.TestCas
def test_dict_keys(self):
data = {'a': 12, 'b': 44}
- self.assertItemsEqual(['a', 'b'], self.eval('$.keys()', data=data))
+ self.assertCountEqual(['a', 'b'], self.eval('$.keys()', data=data))
def test_dict_values(self):
data = {'a': 12, 'b': 44}
- self.assertItemsEqual([12, 44], self.eval('$.values()', data=data))
+ self.assertCountEqual([12, 44], self.eval('$.values()', data=data))
def test_dict_items(self):
data = {'a': 12, 'b': 44}
- self.assertItemsEqual([['a', 12], ['b', 44]],
+ self.assertCountEqual([['a', 12], ['b', 44]],
self.eval('$.items()', data=data))
self.assertEqual(data, self.eval('dict($.items())', data=data))
@@ -231,11 +231,11 @@ class TestCollections(yaql.tests.TestCas
self.eval('dict(a => 1) + dict(b => 2)'))
def test_list_multiplication(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[1, 2, 1, 2, 1, 2],
self.eval('3 * [1, 2]'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[1, 2, 1, 2, 1, 2],
self.eval('[1, 2] * 3'))
@@ -392,7 +392,7 @@ class TestCollections(yaql.tests.TestCas
self.eval('$.deleteAll([b, c])', data=data))
def test_set(self):
- self.assertItemsEqual([2, 1, 3], self.eval('set(1, 2, 3, 2, 1)'))
+ self.assertCountEqual([2, 1, 3], self.eval('set(1, 2, 3, 2, 1)'))
self.assertEqual([[1, 2, 3, 2, 1]], self.eval('set([1, 2, 3, 2, 1])'))
self.assertEqual([], self.eval('set()'))
self.assertEqual(
@@ -400,13 +400,13 @@ class TestCollections(yaql.tests.TestCas
self.eval('set({a => {b => c}})'))
def test_set_from_iterator(self):
- self.assertItemsEqual([2, 1, 3], self.eval('set([1, 2, 3].select($))'))
+ self.assertCountEqual([2, 1, 3], self.eval('set([1, 2, 3].select($))'))
def test_to_set(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[2, 1, 3], self.eval('[1, 2, 3].select($).toSet()'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[2, 1, 3], self.eval('[1, 2, 3].toSet()'))
def test_set_len(self):
@@ -414,7 +414,7 @@ class TestCollections(yaql.tests.TestCas
self.assertEqual(3, self.eval('len(set(1, 2, 3))'))
def test_set_addition(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 3, 2, 1],
self.eval('set(1, 2, 3) + set(4, 2, 3)'))
@@ -422,7 +422,7 @@ class TestCollections(yaql.tests.TestCas
self.eval('isSet(set(1, 2, 3) + set(4, 2, 3))'))
def test_set_union(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 3, 2, 1],
self.eval('set(1, 2, 3).union(set(4, 2, 3))'))
@@ -451,12 +451,12 @@ class TestCollections(yaql.tests.TestCas
self.assertTrue(self.eval('set(1, 2, 3) <= set(1, 2, 3)'))
def test_set_difference(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 1],
self.eval('set(1, 2, 3, 4).difference(set(2, 3))'))
def test_set_subtraction(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 1],
self.eval('set(1, 2, 3, 4) - set(2, 3)'))
@@ -464,24 +464,24 @@ class TestCollections(yaql.tests.TestCas
self.eval('isSet(set(1, 2, 3, 4) - set(2, 3))'))
def test_set_symmetric_difference(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 1, 5],
self.eval('set(1, 2, 3, 4).symmetricDifference(set(2, 3, 5))'))
def test_set_add(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 1, 2, 3],
self.eval('set(1, 2, 3).add(4)'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 1, 2, 3, 5],
self.eval('set(1, 2, 3).add(4, 5)'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[1, 3, 2, [1, 2]],
self.eval('set(1, 2, 3).add([1, 2])'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[4, 1, None, 2, 3, 5],
self.eval('set(1, 2, 3).add(4, 5, null)'))
@@ -489,19 +489,19 @@ class TestCollections(yaql.tests.TestCas
self.eval('isSet(set(1, 2, 3).add(4, 5, null))'))
def test_set_remove(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
[1, 3],
self.eval('set(1, 2, 3).remove(2)'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[3, None],
self.eval('set(1, 2, null, 3).remove(1, 2, 5)'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[3],
self.eval('set(1, 2, null, 3).remove(1, 2, 5, null)'))
- self.assertItemsEqual(
+ self.assertCountEqual(
[1, 3, 2],
self.eval('set(1, 2, 3, [1, 2]).remove([1, 2])'))
Index: yaql-1.1.3/yaql/tests/test_contexts.py
===================================================================
--- yaql-1.1.3.orig/yaql/tests/test_contexts.py
+++ yaql-1.1.3/yaql/tests/test_contexts.py
@@ -223,9 +223,9 @@ class TestContexts(testtools.TestCase):
def test_multi_context_keys(self):
mc = self.create_multi_context()
- self.assertItemsEqual(['$key4', '$key'], mc.keys())
- self.assertItemsEqual(['$key2'], mc.parent.keys())
- self.assertItemsEqual(['$key3'], mc.parent.parent.keys())
+ self.assertCountEqual(['$key4', '$key'], mc.keys())
+ self.assertCountEqual(['$key2'], mc.parent.keys())
+ self.assertCountEqual(['$key3'], mc.parent.parent.keys())
def test_multi_context_get_functions(self):
def f():
Index: yaql-1.1.3/yaql/tests/test_legacy.py
===================================================================
--- yaql-1.1.3.orig/yaql/tests/test_legacy.py
+++ yaql-1.1.3/yaql/tests/test_legacy.py
@@ -141,4 +141,4 @@ class TestLegacy(TestLegacyNewEngine):
def test_dicts_are_iterable(self):
data = {'a': 1, 'b': 2}
self.assertTrue(self.eval('a in $', data))
- self.assertItemsEqual('ab', self.eval('$.sum()', data))
+ self.assertCountEqual('ab', self.eval('$.sum()', data))
Index: yaql-1.1.3/yaql/tests/test_queries.py
===================================================================
--- yaql-1.1.3.orig/yaql/tests/test_queries.py
+++ yaql-1.1.3/yaql/tests/test_queries.py
@@ -63,9 +63,9 @@ class TestQueries(yaql.tests.TestCase):
def test_distinct_with_selector(self):
data = [['a', 1], ['b', 2], ['c', 1], ['d', 3], ['e', 2]]
- self.assertItemsEqual([['a', 1], ['b', 2], ['d', 3]],
+ self.assertCountEqual([['a', 1], ['b', 2], ['d', 3]],
self.eval('$.distinct($[1])', data=data))
- self.assertItemsEqual([['a', 1], ['b', 2], ['d', 3]],
+ self.assertCountEqual([['a', 1], ['b', 2], ['d', 3]],
self.eval('distinct($, $[1])', data=data))
def test_any(self):
@@ -196,7 +196,7 @@ class TestQueries(yaql.tests.TestCase):
def test_group_by(self):
data = {'a': 1, 'b': 2, 'c': 1, 'd': 3, 'e': 2}
- self.assertItemsEqual(
+ self.assertCountEqual(
[
[1, [['a', 1], ['c', 1]]],
[2, [['b', 2], ['e', 2]]],
@@ -204,23 +204,23 @@ class TestQueries(yaql.tests.TestCase):
],
self.eval('$.items().orderBy($[0]).groupBy($[1])', data=data))
- self.assertItemsEqual(
+ self.assertCountEqual(
[[1, ['a', 'c']], [2, ['b', 'e']], [3, ['d']]],
self.eval('$.items().orderBy($[0]).groupBy($[1], $[0])',
data=data))
- self.assertItemsEqual(
+ self.assertCountEqual(
[[1, 'ac'], [2, 'be'], [3, 'd']],
self.eval('$.items().orderBy($[0]).'
'groupBy($[1], $[0], $.sum())', data=data))
- self.assertItemsEqual(
+ self.assertCountEqual(
[[1, ['a', 1, 'c', 1]], [2, ['b', 2, 'e', 2]], [3, ['d', 3]]],
self.eval('$.items().orderBy($[0]).'
'groupBy($[1],, $.sum())',
data=data))
- self.assertItemsEqual(
+ self.assertCountEqual(
[[1, ['a', 1, 'c', 1]], [2, ['b', 2, 'e', 2]], [3, ['d', 3]]],
self.eval('$.items().orderBy($[0]).'
'groupBy($[1], aggregator => $.sum())',
Index: yaql-1.1.3/yaql/tests/test_strings.py
===================================================================
--- yaql-1.1.3.orig/yaql/tests/test_strings.py
+++ yaql-1.1.3/yaql/tests/test_strings.py
@@ -174,7 +174,7 @@ class TestStrings(yaql.tests.TestCase):
self.assertEqual(['a', 'b', 'c'], self.eval('abc.toCharArray()'))
def test_characters(self):
- self.assertItemsEqual(
+ self.assertCountEqual(
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
self.eval('characters(octdigits => true, digits => true)'))

View File

@ -11,6 +11,8 @@ License: {{ license('Apache-2.0') }}
Group: Development/Languages/Python
URL: https://docs.openstack.org/{{ pypi_name }}
Source0: {{ source }}
# rebased from https://opendev.org/openstack/yaql/commit/0b006f07226138ef26ab8296494f1dc1c09908e2.patch
Patch1: 0b006f07226138ef26ab8296494f1dc1c09908e2.patch
BuildRequires: openstack-macros
# for testing
BuildRequires: {{ py3('Sphinx') }}