From 0285b72ee4aaa5b5e5f1e492ae752fda72c0bab42f73bff27ddeffeb568ae934 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Fri, 20 Dec 2024 04:17:25 +0000 Subject: [PATCH] - Switch to autosetup, pyproject and pyunittest macros. - No more greedy globs in %files. - Add patch no-makesuite.patch: * Use the load tests protocol to run the testsuite. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-BitVector?expand=0&rev=6 --- no-makesuite.patch | 142 +++++++++++++++++++++++++++++++++++++++ python-BitVector.changes | 8 +++ python-BitVector.spec | 19 +++--- 3 files changed, 161 insertions(+), 8 deletions(-) create mode 100644 no-makesuite.patch diff --git a/no-makesuite.patch b/no-makesuite.patch new file mode 100644 index 0000000..672ee25 --- /dev/null +++ b/no-makesuite.patch @@ -0,0 +1,142 @@ +Index: BitVector-3.5.0/TestBitVector/Test.py +=================================================================== +--- BitVector-3.5.0.orig/TestBitVector/Test.py ++++ BitVector-3.5.0/TestBitVector/Test.py +@@ -1,38 +1,8 @@ + #!/usr/bin/env python + + import unittest +-import TestBooleanLogic +-import TestConstructors +-import TestComparisonOps +-import TestPermutations +-import TestCircularShifts ++ + + class BitVectorTestCase( unittest.TestCase ): + def checkVersion(self): + import BitVector +- +- +-testSuites = [unittest.makeSuite(BitVectorTestCase, 'check')] +- +-for test_type in [ +- TestConstructors, +- TestBooleanLogic, +- TestComparisonOps, +- TestPermutations, +- TestCircularShifts, +- ]: +- testSuites.append(test_type.getTestSuites('check')) +- +-def getTestDirectory(): +- try: +- return os.path.abspath(os.path.dirname(__file__)) +- except: +- return '.' +- +-import os +- +-os.chdir(getTestDirectory()) +- +-runner = unittest.TextTestRunner() +-runner.run(unittest.TestSuite(testSuites)) +- +Index: BitVector-3.5.0/TestBitVector/TestBooleanLogic.py +=================================================================== +--- BitVector-3.5.0.orig/TestBitVector/TestBooleanLogic.py ++++ BitVector-3.5.0/TestBitVector/TestBooleanLogic.py +@@ -36,8 +36,3 @@ class BooleanLogicTestCase(unittest.Test + if ( args[0].size == args[1].size ): + print(e) + print(" BOOLEAN LOGIC TEST FAILED") +- +-def getTestSuites(type): +- return unittest.TestSuite([ +- unittest.makeSuite(BooleanLogicTestCase, type) +- ]) +Index: BitVector-3.5.0/TestBitVector/TestCircularShifts.py +=================================================================== +--- BitVector-3.5.0.orig/TestBitVector/TestCircularShifts.py ++++ BitVector-3.5.0/TestBitVector/TestCircularShifts.py +@@ -24,8 +24,3 @@ class CircularShiftTestCase(unittest.Tes + except Exception as e: + print(e) + print(" CIRCULAR SHIFT TEST FAILED") +- +-def getTestSuites(type): +- return unittest.TestSuite([ +- unittest.makeSuite(CircularShiftTestCase, type) +- ]) +Index: BitVector-3.5.0/TestBitVector/TestComparisonOps.py +=================================================================== +--- BitVector-3.5.0.orig/TestBitVector/TestComparisonOps.py ++++ BitVector-3.5.0/TestBitVector/TestComparisonOps.py +@@ -39,8 +39,3 @@ class ComparisonTestCases(unittest.TestC + except Exception as e: + print(e) + print(" COMPARISON TEST FAILED") +- +-def getTestSuites(type): +- return unittest.TestSuite([ +- unittest.makeSuite(ComparisonTestCases, type) +- ]) +Index: BitVector-3.5.0/TestBitVector/TestConstructors.py +=================================================================== +--- BitVector-3.5.0.orig/TestBitVector/TestConstructors.py ++++ BitVector-3.5.0/TestBitVector/TestConstructors.py +@@ -11,7 +11,7 @@ constructorTests = [ + (('intVal', '5678'), '1011000101110'), + (('bitstring', '00110011'), '00110011'), + (('streamobject', '111100001111'), '111100001111'), +- (('filename', 'testinput1.txt'), '0100000100100000011010000111010101101110011001110111001001111001'), ++ (('filename', 'TestBitVector/testinput1.txt'), '0100000100100000011010000111010101101110011001110111001001111001'), + ] + + class ConstructorTestCases(unittest.TestCase): +@@ -43,8 +43,3 @@ class ConstructorTestCases(unittest.Test + except Exception as e: + print(e) + print(" CONSTRUCTOR TEST FAILED") +- +-def getTestSuites(type): +- return unittest.TestSuite([ +- unittest.makeSuite(ConstructorTestCases, type) +- ]) +Index: BitVector-3.5.0/TestBitVector/TestPermutations.py +=================================================================== +--- BitVector-3.5.0.orig/TestBitVector/TestPermutations.py ++++ BitVector-3.5.0/TestBitVector/TestPermutations.py +@@ -24,8 +24,3 @@ class PermutationTestCase(unittest.TestC + except Exception as e: + print(e) + print("Permutation test failed") +- +-def getTestSuites(type): +- return unittest.TestSuite([ +- unittest.makeSuite(PermutationTestCase, type) +- ]) +Index: BitVector-3.5.0/TestBitVector/__init__.py +=================================================================== +--- /dev/null ++++ BitVector-3.5.0/TestBitVector/__init__.py +@@ -0,0 +1,19 @@ ++import os ++import unittest ++ ++ ++def getTestDirectory(): ++ try: ++ return os.path.abspath(os.path.dirname(__file__)) ++ except: ++ return '.' ++ ++ ++def load_tests(loader, tests, pattern): ++ loader.testMethodPrefix = 'check' ++ tests.addTests(loader.discover(start_dir=getTestDirectory(), pattern="Test*.py")) ++ return tests ++ ++ ++if __name__ == '__main__': ++ unittest.main() diff --git a/python-BitVector.changes b/python-BitVector.changes index 72a122a..e1c9d0b 100644 --- a/python-BitVector.changes +++ b/python-BitVector.changes @@ -1,3 +1,11 @@ +------------------------------------------------------------------- +Fri Dec 20 04:15:58 UTC 2024 - Steve Kowalik + +- Switch to autosetup, pyproject and pyunittest macros. +- No more greedy globs in %files. +- Add patch no-makesuite.patch: + * Use the load tests protocol to run the testsuite. + ------------------------------------------------------------------- Fri Aug 13 13:55:15 UTC 2021 - John Paul Adrian Glaubitz diff --git a/python-BitVector.spec b/python-BitVector.spec index 0095be4..141003c 100644 --- a/python-BitVector.spec +++ b/python-BitVector.spec @@ -1,7 +1,7 @@ # # spec file for package python-BitVector # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,16 +16,18 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-BitVector Version: 3.5.0 Release: 0 Summary: A memory-efficient packed representation for bit arrays in pure Python License: Python-2.0 -Group: Development/Languages/Python URL: https://engineering.purdue.edu/kak/dist/ Source: https://files.pythonhosted.org/packages/source/B/BitVector/BitVector-%{version}.tar.gz +# PATCH-FIX-OPENSUSE Use load tests protocol to run the testsuite +Patch0: no-makesuite.patch +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch @@ -40,20 +42,21 @@ applications such as computer security, computer vision, etc. %prep -%setup -q -n BitVector-%{version} +%autosetup -p1 -n BitVector-%{version} %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} %check -%python_expand $python TestBitVector/Test.py +%pyunittest -v TestBitVector %files %{python_files} %doc README -%{python_sitelib}/* +%{python_sitelib}/BitVector +%{python_sitelib}/BitVector-%{version}.dist-info %changelog