コード例 #1
0
ファイル: test_utils.py プロジェクト: digambar15/nova
    def test_single_wrapped(self):
        @self._wrapper
        def wrapped(self, instance, red=None, blue=None):
            pass

        func = utils.get_wrapped_function(wrapped)
        func_code = func.__code__
        self.assertEqual(4, len(func_code.co_varnames))
        self.assertIn('self', func_code.co_varnames)
        self.assertIn('instance', func_code.co_varnames)
        self.assertIn('red', func_code.co_varnames)
        self.assertIn('blue', func_code.co_varnames)
コード例 #2
0
ファイル: test_utils.py プロジェクト: BenoitKnecht/nova
    def test_single_wrapped(self):
        @self._wrapper
        def wrapped(self, instance, red=None, blue=None):
            pass

        func = utils.get_wrapped_function(wrapped)
        func_code = func.func_code
        self.assertEqual(4, len(func_code.co_varnames))
        self.assertIn("self", func_code.co_varnames)
        self.assertIn("instance", func_code.co_varnames)
        self.assertIn("red", func_code.co_varnames)
        self.assertIn("blue", func_code.co_varnames)
コード例 #3
0
ファイル: test_utils.py プロジェクト: prometheanfire/nova
    def test_single_wrapped(self):
        @self._wrapper
        def wrapped(self, instance, red=None, blue=None):
            pass

        func = utils.get_wrapped_function(wrapped)
        func_code = func.func_code
        self.assertEqual(4, len(func_code.co_varnames))
        self.assertTrue('self' in func_code.co_varnames)
        self.assertTrue('instance' in func_code.co_varnames)
        self.assertTrue('red' in func_code.co_varnames)
        self.assertTrue('blue' in func_code.co_varnames)
コード例 #4
0
    def test_double_wrapped(self):
        @self._wrapper
        @self._wrapper
        def wrapped(self, instance, red=None, blue=None):
            pass

        func = utils.get_wrapped_function(wrapped)
        func_code = func.func_code
        self.assertEqual(4, len(func_code.co_varnames))
        self.assertTrue('self' in func_code.co_varnames)
        self.assertTrue('instance' in func_code.co_varnames)
        self.assertTrue('red' in func_code.co_varnames)
        self.assertTrue('blue' in func_code.co_varnames)
コード例 #5
0
ファイル: test_utils.py プロジェクト: wentao1101/nova
    def test_double_wrapped(self):
        @self._wrapper
        @self._wrapper
        def wrapped(self, instance, red=None, blue=None):
            pass

        func = utils.get_wrapped_function(wrapped)
        func_code = func.__code__
        self.assertEqual(4, len(func_code.co_varnames))
        self.assertIn('self', func_code.co_varnames)
        self.assertIn('instance', func_code.co_varnames)
        self.assertIn('red', func_code.co_varnames)
        self.assertIn('blue', func_code.co_varnames)
コード例 #6
0
ファイル: test_driver.py プロジェクト: apporc/nova
    def test_public_api_signatures(self):
        # NOTE(claudiub): wrapped functions do not keep the same signature in
        # Python 2.7, which causes this test to fail. Instead, we should
        # compare the public API signatures of the unwrapped methods.

        for attr in driver.HyperVDriver.__dict__:
            class_member = getattr(driver.HyperVDriver, attr)
            if callable(class_member):
                mocked_method = mock.patch.object(
                    driver.HyperVDriver, attr,
                    utils.get_wrapped_function(class_member))
                mocked_method.start()
                self.addCleanup(mocked_method.stop)

        self.assertPublicAPISignatures(base_driver.ComputeDriver,
                                       driver.HyperVDriver)