diff options
author | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2011-01-10 18:52:40 +0100 |
---|---|---|
committer | Legrandin <gooksankoo@hoiptorrow.mailexpire.com> | 2011-01-10 18:52:40 +0100 |
commit | abd276c5fa31abf0b1d70ca4624e30cdacaee867 (patch) | |
tree | 4522ec6ad8926e9d382947c586a3305ca337b9d0 /setup.py | |
parent | 3c193d7b1097eac78592e22e1cad4f4249f7d9d3 (diff) | |
download | pycrypto-abd276c5fa31abf0b1d70ca4624e30cdacaee867.tar.gz |
Improve the test command in setup.py, by allowing tests to be
performed on a single sub-package or module only.
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -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 |