forked from pool/python-textfsm
Accepting request 620236 from home:aplanas:branches:devel:languages:python
- Add textfsm_test_do_not_relay_on_dic_order.patch to enable tests in Python2 and Python3 OBS-URL: https://build.opensuse.org/request/show/620236 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-textfsm?expand=0&rev=3
This commit is contained in:
committed by
Git OBS Bridge
parent
2e327992bc
commit
88c9d1af5f
@@ -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
|
Thu Jun 21 07:33:03 UTC 2018 - tchvatal@suse.com
|
||||||
|
|
||||||
|
@@ -25,11 +25,13 @@ License: Apache-2.0
|
|||||||
Group: Development/Languages/Python
|
Group: Development/Languages/Python
|
||||||
Url: https://github.com/google/textfsm
|
Url: https://github.com/google/textfsm
|
||||||
Source: https://github.com/google/textfsm/archive/0.4.1.tar.gz
|
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 setuptools}
|
||||||
BuildRequires: %{python_module six}
|
BuildRequires: %{python_module six}
|
||||||
|
BuildRequires: fdupes
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros
|
||||||
Requires: python-six
|
Requires: python-six
|
||||||
BuildRequires: fdupes
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%python_subpackages
|
%python_subpackages
|
||||||
@@ -42,6 +44,7 @@ devices.
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n textfsm-%{version}
|
%setup -q -n textfsm-%{version}
|
||||||
|
%patch0 -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%python_build
|
%python_build
|
||||||
@@ -54,8 +57,7 @@ devices.
|
|||||||
%python_exec clitable_test.py
|
%python_exec clitable_test.py
|
||||||
%python_exec copyable_regex_object_test.py
|
%python_exec copyable_regex_object_test.py
|
||||||
%python_exec terminal_test.py
|
%python_exec terminal_test.py
|
||||||
# textfsm_test.py is not working under python2
|
%python_exec textfsm_test.py
|
||||||
python3 textfsm_test.py
|
|
||||||
%python_exec texttable_test.py
|
%python_exec texttable_test.py
|
||||||
|
|
||||||
%files %{python_files}
|
%files %{python_files}
|
||||||
|
36
textfsm_test_do_not_relay_on_dic_order.patch
Normal file
36
textfsm_test_do_not_relay_on_dic_order.patch
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
From 0a1b2a33a4e8ef0484c9f8051ff0b69874ca05e1 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Alberto Planas <aplanas@gmail.com>
|
||||||
|
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):
|
Reference in New Issue
Block a user