本文整理汇总了Python中six.moves.reload_module函数的典型用法代码示例。如果您正苦于以下问题:Python reload_module函数的具体用法?Python reload_module怎么用?Python reload_module使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reload_module函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDown
def tearDown(self):
super(RbacHorizonTests, self).tearDown()
# Restore our settings
settings.HORIZON_CONFIG['default_dashboard'] = self.old_default_dash
settings.HORIZON_CONFIG['dashboards'] = self.old_dashboards
# Destroy our singleton and re-create it.
base.HorizonSite._instance = None
del base.Horizon
base.Horizon = base.HorizonSite()
# Reload the convenience references to Horizon stored in __init__
moves.reload_module(import_module("horizon"))
# Reset Cats and Dogs default_panel to default values
Cats.default_panel = 'kittens'
Dogs.default_panel = 'puppies'
# Re-register our original dashboards and panels.
# This is necessary because autodiscovery only works on the first
# import, and calling reload introduces innumerable additional
# problems. Manual re-registration is the only good way for testing.
self._discovered_dashboards.remove(Cats)
self._discovered_dashboards.remove(Dogs)
for dash in self._discovered_dashboards:
base.Horizon.register(dash)
for panel in self._discovered_panels[dash]:
dash.register(panel)
示例2: verify
def verify(request_type, success_url=None, failure_url=None, **kwargs):
"""
Call the verify view function. All kwargs not specified above will be passed
as GET or POST arguments.
"""
if request_type == 'get':
request = factory.get('/browserid/verify', kwargs)
else:
request = factory.post('/browserid/verify', kwargs)
# Patch settings prior to importing verify
patches = {'BROWSERID_CREATE_USER': True, 'SITE_URL': 'http://testserver'}
if success_url is not None:
patches['LOGIN_REDIRECT_URL'] = success_url
if failure_url is not None:
patches['LOGIN_REDIRECT_URL_FAILURE'] = failure_url
# We need to reload verify for the setting changes to take effect.
with patch_settings(**patches):
reload_module(views)
verify_view = views.Verify.as_view()
with patch.object(auth, 'login'):
response = verify_view(request)
return response
示例3: fin
def fin():
monkeypatch.undo()
reload_module(sherpa)
reload_module(plot)
reload_module(astro_plot)
reload_module(sherpa.all)
reload_module(sherpa.astro.all) # These are required because otherwise Python will not match imported classes.
示例4: test_channel
def test_channel(sol):
config.update(
{
'Re': 8000.,
'nu': 1./8000., # Viscosity
'dt': 0.001, # Time step
'T': 0.01, # End time
'L': [2, 2*pi, 4*pi/3.],
'M': [7, 5, 2],
'eps': 1e-7
}, "channel"
)
solver = get_solver(regression_test=regression_test,
mesh="channel",
parse_args=[sol])
context = solver.get_context()
initialize(solver, context)
set_Source(**context)
solve(solver, context)
config.params.dealias = '3/2-rule'
config.params.optimization = 'cython'
reload_module(solver) # Need to reload to enable optimization
initialize(solver, context)
solve(solver, context)
config.params.dealias_cheb = True
config.params.checkpoint = 5
config.params.write_result = 2
initialize(solver, context)
solve(solver, context)
示例5: setUp
def setUp(self):
reload_module(local)
self.tmpdir = tempfile.mkdtemp()
self.key_file = os.path.join(self.tmpdir, 'key')
self.patcher = mock.patch('secretcrypt.local._key_dir')
mock_key_dir = self.patcher.start()
mock_key_dir.return_value = self.tmpdir
示例6: test_all_public_methods_are_traced
def test_all_public_methods_are_traced(self):
profiler_opts.set_defaults(conf.CONF)
self.config(enabled=True,
group='profiler')
classes = [
'magnum.conductor.api.API',
'magnum.conductor.api.ListenerAPI',
'magnum.conductor.handlers.ca_conductor.Handler',
'magnum.conductor.handlers.cluster_conductor.Handler',
'magnum.conductor.handlers.conductor_listener.Handler',
'magnum.conductor.handlers.indirection_api.Handler',
'magnum.service.periodic.MagnumPeriodicTasks',
]
for clsname in classes:
# give the metaclass and trace_cls() decorator a chance to patch
# methods of the classes above
six.reload_module(
importutils.import_module(clsname.rsplit('.', 1)[0]))
cls = importutils.import_class(clsname)
for attr, obj in cls.__dict__.items():
# only public methods are traced
if attr.startswith('_'):
continue
# only checks callables
if not (inspect.ismethod(obj) or inspect.isfunction(obj)):
continue
# osprofiler skips static methods
if isinstance(obj, staticmethod):
continue
self.assertTrue(getattr(obj, '__traced__', False), obj)
示例7: testHalfDuplexCallWedged
def testHalfDuplexCallWedged(self):
import protoc_plugin_test_pb2 as test_pb2 # pylint: disable=g-import-not-at-top
moves.reload_module(test_pb2)
condition = threading.Condition()
wait_cell = [False]
@contextlib.contextmanager
def wait(): # pylint: disable=invalid-name
# Where's Python 3's 'nonlocal' statement when you need it?
with condition:
wait_cell[0] = True
yield
with condition:
wait_cell[0] = False
condition.notify_all()
def half_duplex_request_iterator():
request = test_pb2.StreamingOutputCallRequest()
request.response_parameters.add(size=1, interval_us=0)
yield request
with condition:
while wait_cell[0]:
condition.wait()
with _CreateService(test_pb2) as (methods, stub):
with wait():
responses = stub.HalfDuplexCall(
half_duplex_request_iterator(), test_constants.SHORT_TIMEOUT)
# half-duplex waits for the client to send all info
with self.assertRaises(face.ExpirationError):
next(responses)
示例8: _test_enforce_network_driver_types_create
def _test_enforce_network_driver_types_create(
self,
network_driver_type,
network_driver_config_dict,
coe='kubernetes',
assert_raised=False):
@v.enforce_network_driver_types_create()
def test(self, baymodel):
pass
for key, val in network_driver_config_dict.items():
cfg.CONF.set_override(key, val, 'baymodel')
baymodel = mock.MagicMock()
baymodel.name = 'test_baymodel'
baymodel.network_driver = network_driver_type
baymodel.coe = coe
# Reload the validator module so that baymodel configs are
# re-evaluated.
reload_module(v)
validator = v.K8sValidator
validator.supported_drivers = ['flannel', 'type1', 'type2']
if assert_raised:
self.assertRaises(exception.InvalidParameterValue,
test, self, baymodel)
else:
test(self, baymodel)
return baymodel
示例9: test_schema_local
def test_schema_local():
def __test(ns_key):
# Get the schema
schema = jams.schema.namespace(ns_key)
# Make sure it has the correct properties
valid_keys = set(['time', 'duration', 'value', 'confidence'])
for key in schema['properties']:
assert key in valid_keys
for key in ['time', 'duration']:
assert key in schema['properties']
os.environ['JAMS_SCHEMA_DIR'] = resource_filename(jams.__name__,
os.path.join('tests',
'fixtures',
'schema'))
# Namespace should not exist yet
test_ns = 'testing_tag_upper'
yield raises(NamespaceError)(__test), test_ns
reload_module(jams)
# Now it should
yield __test, test_ns
del os.environ['JAMS_SCHEMA_DIR']
示例10: setUp
def setUp(self):
super(OAuth2RequiredDecoratorTest, self).setUp()
self.save_settings = copy.deepcopy(django.conf.settings)
reload_module(oauth2client.contrib.django_util)
self.user = User.objects.create_user(
username='bill', email='[email protected]', password='hunter2')
示例11: generate_hierarchy_from_module
def generate_hierarchy_from_module(module):
from .case import is_testcase_subclass
if isinstance(module, str):
module = importlib.import_module(module)
logger.debug("reload %s", module)
reload_module(module)
children = []
for attr_name in dir(module):
obj = getattr(module, attr_name)
if is_testcase_subclass(obj) and not inspect.isabstract(obj):
case_hierarchy = generate_hierarchy_from_testcase_class(obj)
if case_hierarchy["children"]:
children.append(case_hierarchy)
imp_loader = pkgutil.get_loader(module)
if imp_loader.is_package(module.__name__):
for module_loader, sub_module_name, is_pkg in pkgutil.iter_modules(path=module.__path__):
sub_suite_module = importlib.import_module(module.__name__ + "." + sub_module_name)
sub_suite_hierarchy = generate_hierarchy_from_module(sub_suite_module)
if sub_suite_hierarchy["children"]:
children.append(sub_suite_hierarchy)
return {"id": module.__name__, "name": module.__name__.rpartition(".")[2], "children": children}
示例12: test_NS2D
def test_NS2D(args):
config.update(
{
'nu': 0.01,
'dt': 0.05,
'T': 10
}, 'doublyperiodic')
solver = get_solver(regression_test=regression_test,
mesh='doublyperiodic',
parse_args=args)
context = solver.get_context()
initialize(solver, **context)
solve(solver, context)
config.params.dealias = '3/2-rule'
initialize(solver, **context)
solve(solver, context)
config.params.dealias = '2/3-rule'
config.params.optimization = 'cython'
reload_module(solver)
initialize(solver, **context)
solve(solver, context)
config.params.write_result = 1
config.params.checkpoint = 1
config.params.dt = 0.01
config.params.t = 0.0
config.params.tstep = 0
config.params.T = 0.04
solver.regression_test = lambda c: None
initialize(solver, **context)
solve(solver, context)
示例13: setup_sdk_imports
def setup_sdk_imports():
"""Sets up appengine SDK third-party imports."""
if six.PY3:
return
if 'GAE_SDK_PATH' not in os.environ:
return
sys.path.insert(0, os.environ['GAE_SDK_PATH'])
if 'google' in sys.modules:
# Some packages, such as protobuf, clobber the google
# namespace package. This prevents that.
try:
reload_module(sys.modules['google'])
except ImportError:
pass
# This sets up google-provided libraries.
import dev_appserver
dev_appserver.fix_sys_path()
# Fixes timezone and other os-level items.
import google.appengine.tools.os_compat
(google.appengine.tools.os_compat)
示例14: _test_enforce_volume_driver_types_update
def _test_enforce_volume_driver_types_update(
self,
mock_get_resource,
mock_pecan_request,
volume_driver_type,
op,
assert_raised=False):
@v.enforce_volume_driver_types_update()
def test(self, baymodel_ident, patch):
pass
baymodel_ident = 'test_uuid_or_name'
patch = [{'path': '/volume_driver', 'value': volume_driver_type,
'op': op}]
context = mock_pecan_request.context
baymodel = obj_utils.get_test_baymodel(context,
uuid=baymodel_ident,
coe='kubernetes')
mock_get_resource.return_value = baymodel
# Reload the validator module so that baymodel configs are
# re-evaluated.
reload_module(v)
validator = v.K8sValidator
validator.supported_volume_driver = ['cinder']
if assert_raised:
self.assertRaises(exception.InvalidParameterValue,
test, self, baymodel_ident, patch)
else:
test(self, baymodel_ident, patch)
mock_get_resource.assert_called_once_with(
'BayModel', baymodel_ident)
示例15: _set_bedtools_path
def _set_bedtools_path(path=""):
old_path = settings._bedtools_path
settings._bedtools_path = path
if old_path != path:
reload_module(bedtool)
reload_module(pybedtools)
return True