summaryrefslogtreecommitdiff
path: root/dev-python/pycryptodome/files/pycryptodome-3.19.0-fix-verbosity-in-tests.patch
diff options
context:
space:
mode:
Diffstat (limited to 'dev-python/pycryptodome/files/pycryptodome-3.19.0-fix-verbosity-in-tests.patch')
-rw-r--r--dev-python/pycryptodome/files/pycryptodome-3.19.0-fix-verbosity-in-tests.patch120
1 files changed, 120 insertions, 0 deletions
diff --git a/dev-python/pycryptodome/files/pycryptodome-3.19.0-fix-verbosity-in-tests.patch b/dev-python/pycryptodome/files/pycryptodome-3.19.0-fix-verbosity-in-tests.patch
new file mode 100644
index 000000000000..7d54e5e4c2a7
--- /dev/null
+++ b/dev-python/pycryptodome/files/pycryptodome-3.19.0-fix-verbosity-in-tests.patch
@@ -0,0 +1,120 @@
+https://github.com/Legrandin/pycryptodome/issues/765
+https://github.com/Legrandin/pycryptodome/commit/87ff66373a5b80cddc9b0dd76e9bb8c15f6a8e50
+
+From 87ff66373a5b80cddc9b0dd76e9bb8c15f6a8e50 Mon Sep 17 00:00:00 2001
+From: Helder Eijs <helderijs@gmail.com>
+Date: Sun, 17 Sep 2023 23:32:02 +0200
+Subject: [PATCH] Fix verbosity problem in tests
+
+--- a/lib/Crypto/SelfTest/Protocol/test_ecdh.py
++++ b/lib/Crypto/SelfTest/Protocol/test_ecdh.py
+@@ -72,6 +72,8 @@ def ecdh_test_rev(self,
+
+ class TestVectorsECDHWycheproof(unittest.TestCase):
+
++ desc = "Wycheproof ECDH tests"
++
+ def add_tests(self, filename):
+
+ def curve(g):
+@@ -107,7 +109,6 @@ def shortDescription(self):
+ return self.desc
+
+ def test_verify(self, tv):
+- self._id = "Wycheproof ECDH Verify Test #%d (%s, %s)" % (tv.id, tv.comment, tv.filename)
+
+ if len(tv.public) == 0:
+ return
+@@ -138,7 +139,7 @@ def test_verify(self, tv):
+
+ def runTest(self):
+ for tv in self.tv:
+- self.desc = "Test #%d (%s) - %s" % (tv.id, tv.filename, tv.comment)
++ self.desc = "Wycheproof ECDH Verify Test #%d (%s, %s)" % (tv.id, tv.comment, tv.filename)
+ self.test_verify(tv)
+
+
+--- a/lib/Crypto/SelfTest/__init__.py
++++ b/lib/Crypto/SelfTest/__init__.py
+@@ -28,18 +28,19 @@
+ application runs.
+ """
+
+-__revision__ = "$Id$"
+-
+ import sys
+ import unittest
++from importlib import import_module
+ from Crypto.Util.py3compat import StringIO
+
++
+ class SelfTestError(Exception):
+ def __init__(self, message, result):
+ Exception.__init__(self, message, result)
+ self.message = message
+ self.result = result
+
++
+ def run(module=None, verbosity=0, stream=None, tests=None, config=None, **kwargs):
+ """Execute self-tests.
+
+@@ -77,21 +78,25 @@ def run(module=None, verbosity=0, stream=None, tests=None, config=None, **kwargs
+ raise SelfTestError("Self-test failed", result)
+ return result
+
++
+ def get_tests(config={}):
+ tests = []
+- from Crypto.SelfTest import Cipher; tests += Cipher.get_tests(config=config)
+- from Crypto.SelfTest import Hash; tests += Hash.get_tests(config=config)
+- from Crypto.SelfTest import Protocol; tests += Protocol.get_tests(config=config)
+- from Crypto.SelfTest import PublicKey; tests += PublicKey.get_tests(config=config)
+- from Crypto.SelfTest import Random; tests += Random.get_tests(config=config)
+- from Crypto.SelfTest import Util; tests += Util.get_tests(config=config)
+- from Crypto.SelfTest import Signature; tests += Signature.get_tests(config=config)
+- from Crypto.SelfTest import IO; tests += IO.get_tests(config=config)
+- from Crypto.SelfTest import Math; tests += Math.get_tests(config=config)
++
++ module_names = [
++ "Cipher", "Hash", "Protocol", "PublicKey", "Random",
++ "Util", "Signature", "IO", "Math",
++ ]
++
++ for name in module_names:
++ module = import_module("Crypto.SelfTest." + name)
++ tests += module.get_tests(config=config)
++
+ return tests
+
++
+ if __name__ == '__main__':
+- suite = lambda: unittest.TestSuite(get_tests())
++ def suite():
++ return unittest.TestSuite(get_tests())
+ unittest.main(defaultTest='suite')
+
+ # vim:set ts=4 sw=4 sts=4 expandtab:
+--- a/lib/Crypto/SelfTest/__main__.py
++++ b/lib/Crypto/SelfTest/__main__.py
+@@ -26,7 +26,7 @@
+
+ from Crypto import SelfTest
+
+-slow_tests = not "--skip-slow-tests" in sys.argv
++slow_tests = not ("--skip-slow-tests" in sys.argv)
+ if not slow_tests:
+ print("Skipping slow tests")
+
+@@ -34,5 +34,10 @@
+ if wycheproof_warnings:
+ print("Printing Wycheproof warnings")
+
+-config = {'slow_tests' : slow_tests, 'wycheproof_warnings' : wycheproof_warnings }
+-SelfTest.run(stream=sys.stdout, verbosity=1, config=config)
++if "-v" in sys.argv:
++ verbosity=2
++else:
++ verbosity=1
++
++config = {'slow_tests': slow_tests, 'wycheproof_warnings': wycheproof_warnings}
++SelfTest.run(stream=sys.stdout, verbosity=verbosity, config=config)