本文整理汇总了Python中types.ModuleType.extra方法的典型用法代码示例。如果您正苦于以下问题:Python ModuleType.extra方法的具体用法?Python ModuleType.extra怎么用?Python ModuleType.extra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类types.ModuleType
的用法示例。
在下文中一共展示了ModuleType.extra方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_build_artifacts_success
# 需要导入模块: from types import ModuleType [as 别名]
# 或者: from types.ModuleType import extra [as 别名]
def test_build_artifacts_success(self):
# inject dummy module and add cleanup
mod = ModuleType('calmjs_testing_dummy')
mod.extra = generic_builder
mod.complete = generic_builder
mod.partial = generic_builder
self.addCleanup(sys.modules.pop, 'calmjs_testing_dummy')
sys.modules['calmjs_testing_dummy'] = mod
working_dir = utils.mkdtemp(self)
utils.make_dummy_dist(self, (
('requires.txt', '\n'.join([
'calmjs',
])),
('entry_points.txt', '\n'.join([
'[calmjs.artifacts]',
'artifact.js = calmjs_testing_dummy:complete',
'partial.js = calmjs_testing_dummy:partial',
])),
), 'app', '1.0', working_dir=working_dir)
# mock a version of calmjs within that environment too
utils.make_dummy_dist(self, (
('entry_points.txt', ''),
), 'calmjs', '1.0', working_dir=working_dir)
def version(bin_path, version_flag='-v', kw={}):
return '0.0.0'
mock_ws = WorkingSet([working_dir])
utils.stub_item_attr_value(self, dist, 'default_working_set', mock_ws)
utils.stub_item_attr_value(
self, artifact, 'get_bin_version_str', version)
registry = ArtifactRegistry('calmjs.artifacts', _working_set=mock_ws)
# quick check of the artifact metadata beforehand
self.assertEqual({}, registry.get_artifact_metadata('app'))
registry.process_package('app')
complete = list(registry.resolve_artifacts_by_builder_compat(
['app'], 'complete'))
partial = list(registry.resolve_artifacts_by_builder_compat(
['app'], 'partial'))
self.assertEqual(len(complete), 1)
self.assertEqual(len(partial), 1)
self.assertEqual(basename(complete[0]), 'artifact.js')
self.assertEqual(basename(partial[0]), 'partial.js')
with open(complete[0]) as fd:
self.assertEqual(fd.read(), 'app')
with open(partial[0]) as fd:
self.assertEqual(fd.read(), 'app')
self.assertEqual({
'calmjs_artifacts': {
'artifact.js': {
'builder': 'calmjs_testing_dummy:complete',
'toolchain_bases': [
{'calmjs.testing.artifact:ArtifactToolchain': {
'project_name': 'calmjs',
'version': '1.0',
}},
{'calmjs.toolchain:NullToolchain': {
'project_name': 'calmjs',
'version': '1.0',
}},
{'calmjs.toolchain:Toolchain': {
'project_name': 'calmjs',
'version': '1.0',
}}
],
'toolchain_bin': ['artifact', '0.0.0'],
},
'partial.js': {
'builder': 'calmjs_testing_dummy:partial',
'toolchain_bases': [
{'calmjs.testing.artifact:ArtifactToolchain': {
'project_name': 'calmjs',
'version': '1.0'}},
{'calmjs.toolchain:NullToolchain': {
'project_name': 'calmjs',
'version': '1.0',
}},
{'calmjs.toolchain:Toolchain': {
'project_name': 'calmjs',
'version': '1.0',
}}
],
'toolchain_bin': ['artifact', '0.0.0'],
}
},
'versions': [
'app 1.0',
'calmjs 1.0',
]
}, registry.get_artifact_metadata('app'))
#.........这里部分代码省略.........