From eb51036c9b8de72b53bcd2f0754c698d2ad40380 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Mon, 11 Nov 2013 22:45:42 +0000 Subject: Refactor 3 places handling fastmath ImportError so that they call `Crypto.SelfTest.st_common.handle_fastmath_import_error`, thereby eliminiating duplicate code. --- lib/Crypto/SelfTest/PublicKey/test_DSA.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'lib/Crypto/SelfTest/PublicKey/test_DSA.py') diff --git a/lib/Crypto/SelfTest/PublicKey/test_DSA.py b/lib/Crypto/SelfTest/PublicKey/test_DSA.py index 72b9e95..037e087 100644 --- a/lib/Crypto/SelfTest/PublicKey/test_DSA.py +++ b/lib/Crypto/SelfTest/PublicKey/test_DSA.py @@ -225,16 +225,8 @@ def get_tests(config={}): from Crypto.PublicKey import _fastmath tests += list_test_cases(DSAFastMathTest) except ImportError: - from distutils.sysconfig import get_config_var - import inspect - ext_suffix = get_config_var("EXT_SUFFIX") or get_config_var("SO") - _fm_path = os.path.normpath(os.path.dirname(os.path.abspath( - inspect.getfile(inspect.currentframe()))) - +"/../../PublicKey/_fastmath"+ext_suffix) - if os.path.exists(_fm_path): - raise ImportError("While the _fastmath module exists, importing "+ - "it failed. This may point to the gmp or mpir shared library "+ - "not being in the path. _fastmath was found at "+_fm_path) + from Crypto.SelfTest.st_common import handle_fastmath_import_error + handle_fastmath_import_error() tests += list_test_cases(DSASlowMathTest) return tests -- cgit v1.2.1