python3 test failure ImportError: No module named 'exceptions'

Bug #1522551 reported by Corey Bryant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.service
Fix Released
Undecided
Corey Bryant

Bug Description

This test is failing when run with python3.4

======================================================================
FAIL: oslo_service.tests.test_sslutils.SslutilsTestCase.test_is_enabled
oslo_service.tests.test_sslutils.SslutilsTestCase.test_is_enabled
----------------------------------------------------------------------
_StringException: Empty attachments:
  stderr
  stdout

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 1297, in patched
    arg = patching.__enter__()
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 1353, in __enter__
    self.target = self.getter()
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 1520, in <lambda>
    getter = lambda: _importer(target)
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 1206, in _importer
    thing = __import__(import_path)
ImportError: No module named 'exceptions'

Revision history for this message
Corey Bryant (corey.bryant) wrote :

This fixes it but there's probably something more elegant:

+if sys.version_info >= (3,0):
+ runtime_error = "builtins.RuntimeError"
+else:
+ runtime_error = "exceptions.RuntimeError"
+

 class SslutilsTestCase(base.ServiceBaseTestCase):
     """Test cases for sslutils."""
@@ -38,7 +44,7 @@
         self.key_file_name = os.path.join(SSL_CERT_DIR, 'privatekey.key')
         self.ca_file_name = os.path.join(SSL_CERT_DIR, 'ca.crt')

- @mock.patch("exceptions.RuntimeError")
+ @mock.patch(runtime_error)
     @mock.patch("os.path.exists")
     def test_is_enabled(self, exists_mock, runtime_error_mock):

Changed in oslo.service:
assignee: nobody → Corey Bryant (corey.bryant)
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Corey, Weird, we don't see this in our CI. wonder what's the differences are.

Revision history for this message
Corey Bryant (corey.bryant) wrote :

Yeah that is weird. I'm not sure what the difference could be. A quick test should be able to recreate it.

corey:/tmp⟫ python3.4
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import exceptions
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'exceptions'
>>> import builtins
>>> builtins.RuntimeError
<class 'RuntimeError'>
>>> quit()
corey:/tmp⟫ python3.5
Python 3.5.1rc1 (default, Nov 24 2015, 17:47:11)
[GCC 5.2.1 20151123] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import exceptions
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'exceptions'
>>> import builtins
>>> builtins.RuntimeError
<class 'RuntimeError'>
>>>

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :
Changed in oslo.service:
status: New → Fix Committed
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/oslo.service 1.2.0

This issue was fixed in the openstack/oslo.service 1.2.0 release.

Changed in oslo.service:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.