本文整理汇总了Python中six.moves.reload_module方法的典型用法代码示例。如果您正苦于以下问题:Python moves.reload_module方法的具体用法?Python moves.reload_module怎么用?Python moves.reload_module使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类six.moves
的用法示例。
在下文中一共展示了moves.reload_module方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_multi_store
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_add_multi_store(self):
conf = copy.deepcopy(SWIFT_CONF)
conf['default_swift_reference'] = 'store_2'
self.config(group="swift1", **conf)
moves.reload_module(swift)
self.mock_keystone_client()
self.store = Store(self.conf, backend="swift1")
self.store.configure()
expected_swift_size = FIVE_KB
expected_swift_contents = b"*" * expected_swift_size
expected_image_id = str(uuid.uuid4())
image_swift = six.BytesIO(expected_swift_contents)
global SWIFT_PUT_OBJECT_CALLS
SWIFT_PUT_OBJECT_CALLS = 0
loc = 'swift+config://store_2/glance/%s'
expected_location = loc % (expected_image_id)
location, size, checksum, arg = self.store.add(expected_image_id,
image_swift,
expected_swift_size)
self.assertEqual("swift1", arg['store'])
self.assertEqual(expected_location, location)
示例2: test_delete
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete(self):
"""
Test we can delete an existing image in the swift store
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(group="swift1", **conf)
moves.reload_module(swift)
self.mock_keystone_client()
self.store = Store(self.conf, backend="swift1")
self.store.configure()
uri = "swift://%s:key@authurl/glance/%s" % (
self.swift_store_user, FAKE_UUID)
loc = location.get_location_from_uri_and_backend(
uri, "swift1", conf=self.conf)
self.store.delete(loc)
self.assertRaises(exceptions.NotFound, self.store.get, loc)
示例3: test_delete_slo
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete_slo(self, mock_del_obj):
"""
Test we can delete an existing image stored as SLO, static large object
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(group="swift1", **conf)
moves.reload_module(swift)
self.store = Store(self.conf, backend="swift1")
self.store.configure()
uri = "swift://%s:key@authurl/glance/%s" % (self.swift_store_user,
FAKE_UUID2)
loc = location.get_location_from_uri_and_backend(
uri, "swift1", conf=self.conf)
self.store.delete(loc)
self.assertEqual(1, mock_del_obj.call_count)
_, kwargs = mock_del_obj.call_args
self.assertEqual('multipart-manifest=delete',
kwargs.get('query_string'))
示例4: test_delete_nonslo_not_deleted_as_slo
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete_nonslo_not_deleted_as_slo(self, mock_del_obj):
"""
Test that non-SLOs are not being deleted the SLO way
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(group="swift1", **conf)
moves.reload_module(swift)
self.mock_keystone_client()
self.store = Store(self.conf, backend="swift1")
self.store.configure()
uri = "swift://%s:key@authurl/glance/%s" % (self.swift_store_user,
FAKE_UUID)
loc = location.get_location_from_uri_and_backend(
uri, "swift1", conf=self.conf)
self.store.delete(loc)
self.assertEqual(1, mock_del_obj.call_count)
_, kwargs = mock_del_obj.call_args
self.assertIsNone(kwargs.get('query_string'))
示例5: test_delete_with_reference_params
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete_with_reference_params(self):
"""
Test we can delete an existing image in the swift store
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(group="swift1", **conf)
moves.reload_module(swift)
# mock client because v3 uses it to receive auth_info
self.mock_keystone_client()
self.store = Store(self.conf, backend="swift1")
self.store.configure()
uri = "swift+config://ref1/glance/%s" % (FAKE_UUID)
loc = location.get_location_from_uri_and_backend(
uri, "swift1", conf=self.conf)
self.store.delete(loc)
self.assertRaises(exceptions.NotFound, self.store.get, loc)
示例6: test_single_tenant_location
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_single_tenant_location(self):
conf = copy.deepcopy(SWIFT_CONF)
conf['swift_store_container'] = 'container'
conf_file = "glance-swift.conf"
self.swift_config_file = self.copy_data_file(conf_file, self.test_dir)
conf.update({'swift_store_config_file': self.swift_config_file})
conf['default_swift_reference'] = 'ref1'
self.config(group="swift1", **conf)
moves.reload_module(swift)
store = swift.SingleTenantStore(self.conf, backend="swift1")
store.configure()
location = store.create_location('image-id')
self.assertEqual('swift+https', location.scheme)
self.assertEqual('https://example.com', location.swift_url)
self.assertEqual('container', location.container)
self.assertEqual('image-id', location.obj)
self.assertEqual('tenant:user1', location.user)
self.assertEqual('key1', location.key)
示例7: test_add_multi_store
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_add_multi_store(self):
conf = copy.deepcopy(SWIFT_CONF)
conf['default_swift_reference'] = 'store_2'
self.config(**conf)
moves.reload_module(swift)
self.mock_keystone_client()
self.store = Store(self.conf)
self.store.configure()
expected_swift_size = FIVE_KB
expected_swift_contents = b"*" * expected_swift_size
expected_image_id = str(uuid.uuid4())
image_swift = six.BytesIO(expected_swift_contents)
global SWIFT_PUT_OBJECT_CALLS
SWIFT_PUT_OBJECT_CALLS = 0
loc = 'swift+config://store_2/glance/%s'
expected_location = loc % (expected_image_id)
location, size, checksum, multihash, arg = self.store.add(
expected_image_id, image_swift, expected_swift_size, HASH_ALGO)
self.assertEqual(expected_location, location)
示例8: test_delete
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete(self):
"""
Test we can delete an existing image in the swift store
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(**conf)
moves.reload_module(swift)
self.mock_keystone_client()
self.store = Store(self.conf)
self.store.configure()
uri = "swift://%s:key@authurl/glance/%s" % (
self.swift_store_user, FAKE_UUID)
loc = location.get_location_from_uri(uri, conf=self.conf)
self.store.delete(loc)
self.assertRaises(exceptions.NotFound, self.store.get, loc)
示例9: test_delete_nonslo_not_deleted_as_slo
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete_nonslo_not_deleted_as_slo(self, mock_del_obj):
"""
Test that non-SLOs are not being deleted the SLO way
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(**conf)
moves.reload_module(swift)
self.mock_keystone_client()
self.store = Store(self.conf)
self.store.configure()
uri = "swift://%s:key@authurl/glance/%s" % (self.swift_store_user,
FAKE_UUID)
loc = location.get_location_from_uri(uri, conf=self.conf)
self.store.delete(loc)
self.assertEqual(1, mock_del_obj.call_count)
_, kwargs = mock_del_obj.call_args
self.assertIsNone(kwargs.get('query_string'))
示例10: test_delete_with_reference_params
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_delete_with_reference_params(self):
"""
Test we can delete an existing image in the swift store
"""
conf = copy.deepcopy(SWIFT_CONF)
self.config(**conf)
moves.reload_module(swift)
# mock client because v3 uses it to receive auth_info
self.mock_keystone_client()
self.store = Store(self.conf)
self.store.configure()
uri = "swift+config://ref1/glance/%s" % (FAKE_UUID)
loc = location.get_location_from_uri(uri, conf=self.conf)
self.store.delete(loc)
self.assertRaises(exceptions.NotFound, self.store.get, loc)
示例11: test_update
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_update(self):
"""test 'pip update <pypi_package>'."""
output = self.run_command("pip --verbose install rsa==3.2.3", exitcode=0)
self.assertIn("Downloading package", output)
self.assert_did_run_setup(output)
self.assertIn("Package installed: rsa", output)
try:
import rsa
self.reload_module(rsa)
except ImportError as e:
self.logger.info("sys.path = " + str(sys.path))
raise AssertionError("Could not import installed module: " + repr(e))
else:
self.assertEqual(rsa.__version__, "3.2.3")
del rsa
output = self.run_command("pip --verbose update rsa", exitcode=0)
try:
import rsa
self.reload_module(rsa)
except ImportError as e:
self.logger.info("sys.path = " + str(sys.path))
raise AssertionError("Could not import installed module: " + repr(e))
else:
self.assertNotEqual(rsa.__version__, "3.2.3")
del rsa
示例12: testRunsInitCodeOnImportWithFailure
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def testRunsInitCodeOnImportWithFailure(self):
if six.PY2:
self.skipTest('Altair not available in Python 2')
_altair._register_hook()
altair = importlib.import_module('altair')
self.assertNotIn('COLAB_ALTAIR_IMPORT_HOOK_EXCEPTION', os.environ)
self.assertIn('altair', sys.modules)
self.assertEqual('colab', altair.renderers.active)
# Reload of the module should not re-execute code.
# Modify the active renderer and ensure that a reload doesn't reset it to
# colab.
altair.renderers.enable('default')
self.assertEqual('default', altair.renderers.active)
altair = reload_module(altair)
self.assertNotIn('COLAB_ALTAIR_IMPORT_HOOK_EXCEPTION', os.environ)
self.assertIn('altair', sys.modules)
self.assertEqual('default', altair.renderers.active)
示例13: refresh_stevedore
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def refresh_stevedore(namespace=None):
"""Trigger reload of entry points.
Useful to have dynamic loading/unloading of stevedore modules.
"""
# NOTE(sheeprine): pkg_resources doesn't support reload on python3 due to
# defining basestring which is still there on reload hence executing
# python2 related code.
try:
del sys.modules['pkg_resources'].basestring
except AttributeError:
# python2, do nothing
pass
# Force working_set reload
moves.reload_module(sys.modules['pkg_resources'])
# Clear stevedore cache
cache = extension.ExtensionManager.ENTRY_POINT_CACHE
if namespace:
if namespace in cache:
del cache[namespace]
else:
cache.clear()
示例14: test_registry_instance_loads_entrypoints
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_registry_instance_loads_entrypoints():
class MockRunContext(object):
pass
mock_entrypoint = mock.Mock()
mock_entrypoint.load.return_value = MockRunContext
with mock.patch(
"entrypoints.get_group_all", return_value=[mock_entrypoint]
) as mock_get_group_all:
# Entrypoints are registered at import time, so we need to reload the module to register th
# entrypoint given by the mocked extrypoints.get_group_all
reload(mlflow.tracking.context.registry)
assert MockRunContext in _currently_registered_run_context_provider_classes()
mock_get_group_all.assert_called_once_with("mlflow.run_context_provider")
示例15: test_standard_store_registry_with_installed_plugin
# 需要导入模块: from six import moves [as 别名]
# 或者: from six.moves import reload_module [as 别名]
def test_standard_store_registry_with_installed_plugin(tmp_wkdir):
"""This test requires the package in tests/resources/mlflow-test-plugin to be installed"""
reload(mlflow.tracking._tracking_service.utils)
assert "file-plugin" in \
mlflow.tracking._tracking_service.utils._tracking_store_registry._registry.keys()
from mlflow_test_plugin.file_store import PluginFileStore
env = {
_TRACKING_URI_ENV_VAR: "file-plugin:test-path",
}
with mock.patch.dict(os.environ, env):
plugin_file_store = mlflow.tracking._tracking_service.utils._get_store()
assert isinstance(plugin_file_store, PluginFileStore)
assert plugin_file_store.is_plugin