コード例 #1
0
 def testImportChildFromDoesNotLoadLazyParent(self):
     # pylint: disable=g-import-not-at-top
     # pylint: disable=reimported
     # pylint: disable=unused-variable
     importing.lazy_load_module(TEST_MODULE_NAME)
     from tests.unit.core.util.testdata.importing_test_package import test_module
     parent = sys.modules[TEST_PACKAGE_NAME]
     self.AssertNotLoaded(parent)
コード例 #2
0
 def testLoadLazyModuleAttribute(self):
     module = importing.lazy_load_module(TEST_MODULE_NAME)
     self.AssertNotLoaded(module)
     self.assertEqual('test_attribute', module.TEST_ATTRIBUTE)
     self.AssertLoaded(module)
     parent = sys.modules[TEST_PACKAGE_NAME]
     self.AssertLoaded(parent)
コード例 #3
0
 def testImportLazyModule(self):
     # pylint: disable=g-import-not-at-top
     # pylint: disable=reimported
     module = importing.lazy_load_module(TEST_MODULE_NAME)
     from tests.unit.core.util.testdata.importing_test_package import test_module
     self.assertIsInstance(module, importing.LazyImporter)
     self.assertEqual(module, test_module)
コード例 #4
0
#
# Copyright 2018 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Package marker file."""

from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals

from googlecloudsdk.core.util import importing
from googlecloudsdk.core.util import lazy_regex

# Lazy loader doesn't work in some environments, such as par files
try:
    importing.lazy_load_module('googlecloudsdk.api_lib.app.yaml_parsing')
except ImportError:
    pass

lazy_regex.initialize_lazy_compile()
コード例 #5
0
 def testLoadModule(self):
     module = importing.lazy_load_module(TEST_MODULE_NAME)
     self.AssertNotLoaded(module)
     importing._load_module(module)
     self.AssertLoaded(module)
コード例 #6
0
 def testLazyLoadModuleParent(self):
     importing.lazy_load_module(TEST_MODULE_NAME)
     parent = sys.modules[TEST_PACKAGE_NAME]
     self.assertIsInstance(parent, importing.LazyImporter)
     self.AssertNotLoaded(parent)
コード例 #7
0
 def testLazyLoadModuleNonexistentModule(self):
     with self.assertRaises(ImportError):
         importing.lazy_load_module('nonexistent.module')
コード例 #8
0
 def testLazyLoadModule(self):
     module = importing.lazy_load_module(TEST_MODULE_NAME)
     self.assertIsInstance(module, importing.LazyImporter)
     self.AssertNotLoaded(module)