diff --git a/python-textfsm.changes b/python-textfsm.changes index 1e7356d..7a155ef 100644 --- a/python-textfsm.changes +++ b/python-textfsm.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon Jul 2 13:04:39 UTC 2018 - aplanas@suse.com + +- Add textfsm_test_do_not_relay_on_dic_order.patch to enable + tests in Python2 and Python3 + ------------------------------------------------------------------- Thu Jun 21 07:33:03 UTC 2018 - tchvatal@suse.com diff --git a/python-textfsm.spec b/python-textfsm.spec index 6660d52..ae2f3bd 100644 --- a/python-textfsm.spec +++ b/python-textfsm.spec @@ -25,11 +25,13 @@ License: Apache-2.0 Group: Development/Languages/Python Url: https://github.com/google/textfsm Source: https://github.com/google/textfsm/archive/0.4.1.tar.gz +# PATCH-FIX-UPSTREAM textfsm_test_do_not_relay_on_dic_order.patch https://github.com/google/textfsm/pull/33 +Patch0: textfsm_test_do_not_relay_on_dic_order.patch BuildRequires: %{python_module setuptools} BuildRequires: %{python_module six} +BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-six -BuildRequires: fdupes BuildArch: noarch %python_subpackages @@ -42,6 +44,7 @@ devices. %prep %setup -q -n textfsm-%{version} +%patch0 -p1 %build %python_build @@ -54,8 +57,7 @@ devices. %python_exec clitable_test.py %python_exec copyable_regex_object_test.py %python_exec terminal_test.py -# textfsm_test.py is not working under python2 -python3 textfsm_test.py +%python_exec textfsm_test.py %python_exec texttable_test.py %files %{python_files} diff --git a/textfsm_test_do_not_relay_on_dic_order.patch b/textfsm_test_do_not_relay_on_dic_order.patch new file mode 100644 index 0000000..1f10ab2 --- /dev/null +++ b/textfsm_test_do_not_relay_on_dic_order.patch @@ -0,0 +1,36 @@ +From 0a1b2a33a4e8ef0484c9f8051ff0b69874ca05e1 Mon Sep 17 00:00:00 2001 +From: Alberto Planas +Date: Mon, 2 Jul 2018 14:51:21 +0200 +Subject: [PATCH] textfsm_test: do not relay on dic order + +The test `testNestedMatching` compares a list of dictionaries with +a string. In Python 2 (and some versions of Python 3) the order +of a dictionary is not guaranteed, and this makes the test to fail. + +This patch compares the raw result with the raw list, and assetEqual +takes care of the ordering. +--- + textfsm_test.py | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/textfsm_test.py b/textfsm_test.py +index c4f7f2c..e92a17b 100755 +--- a/textfsm_test.py ++++ b/textfsm_test.py +@@ -628,10 +628,12 @@ def testNestedMatching(self): + data = " Bob: 32 NC\n Alice: 27 NY\n Jeff: 45 CA\nJulia\n\n" # Julia should be parsed as "name" separately + result = t.ParseText(data) + self.assertEqual( +- str(result), ( +- "[[[{'name': 'Bob', 'age': '32', 'state': 'NC'}, " +- "{'name': 'Alice', 'age': '27', 'state': 'NY'}, " +- "{'name': 'Jeff', 'age': '45', 'state': 'CA'}], 'Julia']]" ++ result, ( ++ [[[ ++ {'name': 'Bob', 'age': '32', 'state': 'NC'}, ++ {'name': 'Alice', 'age': '27', 'state': 'NY'}, ++ {'name': 'Jeff', 'age': '45', 'state': 'CA'} ++ ], 'Julia']] + )) + + def testNestedNameConflict(self):