summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README7
-rw-r--r--lib/Crypto/SelfTest/PublicKey/test_DSA.py3
-rw-r--r--lib/Crypto/SelfTest/PublicKey/test_RSA.py3
-rw-r--r--setup.py21
4 files changed, 30 insertions, 4 deletions
diff --git a/README b/README
index 7196b63..212d4e6 100644
--- a/README
+++ b/README
@@ -86,6 +86,13 @@ possible, track down the bug and include a patch that fixes it,
provided that you are able to meet the eligibility requirements at
http://www.pycrypto.org/submission-requirements/.
+It is possible to test a single sub-package or a single module only, for instance
+when you investigate why certain tests fail and don't want to run the whole
+suite each time. Use "python setup.py test --module=name", where 'name'
+is either a sub-package (Cipher, PublicKey, etc) or a module (Cipher.DES,
+PublicKey.RSA, etc).
+To further cut test coverage, pass also the option "--skip-slow-tests".
+
To install the package under the site-packages directory of
your Python installation, run "python setup.py install".
diff --git a/lib/Crypto/SelfTest/PublicKey/test_DSA.py b/lib/Crypto/SelfTest/PublicKey/test_DSA.py
index 208a044..0fa7df6 100644
--- a/lib/Crypto/SelfTest/PublicKey/test_DSA.py
+++ b/lib/Crypto/SelfTest/PublicKey/test_DSA.py
@@ -222,7 +222,8 @@ def get_tests(config={}):
tests += list_test_cases(DSAFastMathTest)
except ImportError:
pass
- tests += list_test_cases(DSASlowMathTest)
+ if config.get('slow_tests',1):
+ tests += list_test_cases(DSASlowMathTest)
return tests
if __name__ == '__main__':
diff --git a/lib/Crypto/SelfTest/PublicKey/test_RSA.py b/lib/Crypto/SelfTest/PublicKey/test_RSA.py
index 4c60860..767db2e 100644
--- a/lib/Crypto/SelfTest/PublicKey/test_RSA.py
+++ b/lib/Crypto/SelfTest/PublicKey/test_RSA.py
@@ -371,7 +371,8 @@ def get_tests(config={}):
tests += list_test_cases(RSAFastMathTest)
except ImportError:
pass
- tests += list_test_cases(RSASlowMathTest)
+ if config.get('slow_tests',1):
+ tests += list_test_cases(RSASlowMathTest)
return tests
if __name__ == '__main__':
diff --git a/setup.py b/setup.py
index 37aedef..aae5dc6 100644
--- a/setup.py
+++ b/setup.py
@@ -208,14 +208,17 @@ class TestCommand(Command):
description = "Run self-test"
+ # Long option name, short option name, description
user_options = [
('skip-slow-tests', None,
- 'Skip slow tests')
+ 'Skip slow tests'),
+ ('module=', 'm', 'Test a single module (e.g. Cipher, PublicKey)')
]
def initialize_options(self):
self.build_dir = None
self.skip_slow_tests = None
+ self.module = None
def finalize_options(self):
self.set_undefined_options('install', ('build_lib', 'build_dir'))
@@ -228,7 +231,21 @@ class TestCommand(Command):
try:
sys.path.insert(0, self.build_dir)
from Crypto import SelfTest
- SelfTest.run(verbosity=self.verbose, stream=sys.stdout, config=self.config)
+ moduleObj = None
+ if self.module:
+ if self.module.count('.')==0:
+ # Test a whole a sub-package
+ full_module = "Crypto.SelfTest." + self.module
+ module_name = self.module
+ else:
+ # Test only a module
+ # Assume only one dot is present
+ comps = self.module.split('.')
+ module_name = "test_" + comps[1]
+ full_module = "Crypto.SelfTest." + comps[0] + "." + module_name
+ # Import sub-package or module
+ moduleObj = __import__( full_module, globals(), locals(), module_name )
+ SelfTest.run(module=moduleObj, verbosity=self.verbose, stream=sys.stdout, config=self.config)
finally:
# Restore sys.path
sys.path[:] = old_path