]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Python3: do not use im_self/im_func/func_closure
authorCyril Roelandt <cyril@redhat.com>
Thu, 18 Jun 2015 11:52:28 +0000 (11:52 +0000)
committerCyril Roelandt <cyril@redhat.com>
Fri, 19 Jun 2015 13:10:01 +0000 (15:10 +0200)
One should use __self__, __func__ and __closure__ instead, as they work
with both Python 2 and 3.

Change-Id: I2b2847cfd5b4fa70e45387ff369240227ce9e526
Blueprint: neutron-python3

neutron/tests/unit/common/test_log.py
neutron/tests/unit/common/test_utils.py

index ed396ce7390fe98e75c51373be6dc3ff5f0eff2a..b6ed65b43a346661349a5ccf82e35d31dabc92b7 100644 (file)
@@ -29,7 +29,7 @@ class TestCallLog(base.BaseTestCase):
     def setUp(self):
         super(TestCallLog, self).setUp()
         self.klass = TargetKlass()
-        logger = self.klass.test_method.im_func.func_closure[0].cell_contents
+        logger = self.klass.test_method.__func__.__closure__[0].cell_contents
         self.log_debug = mock.patch.object(logger, 'debug').start()
 
     def _test_call_log(self, *args, **kwargs):
index cee645c8d543f28d9988f8c7b2f6bafc53b7faf8..82c84904c0005e78717b0db28c2a43c3f89f0b9c 100644 (file)
@@ -418,7 +418,7 @@ class TestCachingDecorator(base.BaseTestCase):
         self.func_name = '%(module)s._CachingDecorator.func' % {
             'module': self.__module__
         }
-        self.not_cached = self.decor.func.func.im_self._not_cached
+        self.not_cached = self.decor.func.func.__self__._not_cached
 
     def test_cache_miss(self):
         expected_key = (self.func_name, 1, 2, ('foo', 'bar'))