From e3599d031e605d8dcf970217c3e8d25a525e8e8c44cb67179fc523bdf437ce23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Tue, 4 Jun 2019 08:00:03 +0000 Subject: [PATCH] Accepting request 707402 from home:pgajdos - shortened test.py, https://github.com/jsommers/pytricia/issues/26 - modified sources % test.py OBS-URL: https://build.opensuse.org/request/show/707402 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pytricia?expand=0&rev=9 --- python-pytricia.changes | 7 +++++++ python-pytricia.spec | 4 +++- test.py | 40 ---------------------------------------- 3 files changed, 10 insertions(+), 41 deletions(-) diff --git a/python-pytricia.changes b/python-pytricia.changes index 41366af..e5d909b 100644 --- a/python-pytricia.changes +++ b/python-pytricia.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Jun 4 07:37:32 UTC 2019 - pgajdos@suse.com + +- shortened test.py, https://github.com/jsommers/pytricia/issues/26 +- modified sources + % test.py + ------------------------------------------------------------------- Mon Jun 3 15:12:14 UTC 2019 - pgajdos@suse.com diff --git a/python-pytricia.spec b/python-pytricia.spec index 0453c8c..8683c2a 100644 --- a/python-pytricia.spec +++ b/python-pytricia.spec @@ -27,7 +27,9 @@ Url: https://github.com/jsommers/pytricia Source: https://files.pythonhosted.org/packages/source/p/pytricia/pytricia-%{version}.tar.gz # https://github.com/jsommers/pytricia/issues/25 Source1: https://raw.githubusercontent.com/jsommers/pytricia/master/COPYING.LESSER -Source2: https://raw.githubusercontent.com/jsommers/pytricia/master/test.py +# shorthened https://raw.githubusercontent.com/jsommers/pytricia/master/test.py +# see https://github.com/jsommers/pytricia/issues/26 +Source2: test.py BuildRequires: %{python_module devel} BuildRequires: %{python_module setuptools} BuildRequires: python-rpm-macros diff --git a/test.py b/test.py index ff42c57..7b44194 100644 --- a/test.py +++ b/test.py @@ -411,44 +411,4 @@ class PyTriciaTests(unittest.TestCase): self.assertFalse('1.2.3.0/24' in pyt) - def testRaw(self): - pyt = pytricia.PyTricia(32, socket.AF_INET, True) - prefixes = [ - (b'\x01\x02\x00\x00', 16), - (b'\x01\x02\x02\x00', 24), - (b'\x01\x02\x03\x00', 24), - (b'\x01\x02\x03\x04', 32) - ] - values = ["A", "B", "C", "D"] - for prefix, value in zip(prefixes, values): - pyt.insert(prefix, value) - - with self.assertRaises(ValueError) as cm: - pyt.insert((b'invalid', 24), "Z") - self.assertEqual(pyt.get_key((b'\x01\x02\x02\x02', 30)), (b'\x01\x02\x02\x00', 24)) - self.assertListEqual(sorted(pyt.keys()), sorted(prefixes)) - self.assertEqual(pyt.parent((b'\x01\x02\x03\x04', 32)), (b'\x01\x02\x03\x00', 24)) - self.assertListEqual(list(pyt.children((b'\x01\x02\x03\x00', 24))), [(b'\x01\x02\x03\x04', 32)]) - self.assertListEqual(sorted(list(pyt)), sorted(prefixes)) - - def testRawIP6(self): - pyt = pytricia.PyTricia(128, socket.AF_INET6, True) - prefixes = [ - (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x00\x00', 96+16), - (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x02\x00', 96+24), - (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x00', 96+24), - (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x04', 96+32) - ] - values = ["A", "B", "C", "D"] - for prefix, value in zip(prefixes, values): - pyt.insert(prefix, value) - - self.assertEqual(pyt.get_key((b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x02\x02', 96+30)), (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x02\x00', 96+24)) - self.assertListEqual(sorted(pyt.keys()), sorted(prefixes)) - self.assertEqual(pyt.parent((b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x04', 96+32)), (b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x00', 96+24)) - self.assertListEqual(list(pyt.children((b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x00', 96+24))), [(b'\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\xAA\xBB\xCC\xDD\x01\x02\x03\x04', 96+32)]) - self.assertListEqual(sorted(list(pyt)), sorted(prefixes)) - -if __name__ == '__main__': - unittest.main()