Просмотр исходного кода

Fixed python 2/3 compatibility issue when reraising using six.

nuwan_ag 10 лет назад
Родитель
Сommit
ce1852d0ed
2 измененных файлов с 6 добавлено и 5 удалено
  1. 3 3
      setup.py
  2. 3 2
      test/helpers.py

+ 3 - 3
setup.py

@@ -8,9 +8,9 @@ setup(name='cloudbridge',
       author='Galaxy and GVL Projects',
       author_email='support@genome.edu.au',
       url='http://cloudbridge.readthedocs.org/',
-      install_requires=['bunch>=1.00', 'python-keystoneclient',
-                        'python-novaclient', 'python-cinderclient',
-                        'boto'],
+      install_requires=['bunch>=1.00', 'six>=1.9.0',
+                        'python-keystoneclient', 'python-novaclient',
+                        'python-cinderclient', 'boto'],
       packages=find_packages(),
       license='MIT',
       classifiers=[

+ 3 - 2
test/helpers.py

@@ -2,6 +2,7 @@ from contextlib import contextmanager
 import os
 import sys
 import unittest
+from six import reraise
 
 from cloudbridge.providers.factory import CloudProviderFactory
 
@@ -25,13 +26,13 @@ def exception_action(cleanup_func):
     try:
         yield
     except:
-        _, ex_val, ex_traceback = sys.exc_info()
+        ex_class, ex_val, ex_traceback = sys.exc_info()
         try:
             cleanup_func()
         except:
             pass
         # raise the original exception
-        raise ex_val.with_traceback(ex_traceback)
+        reraise(ex_class, ex_val, ex_traceback)
 
 
 def create_test_instance(provider):