本文整理汇总了Python中distutils.dist.Distribution方法的典型用法代码示例。如果您正苦于以下问题:Python dist.Distribution方法的具体用法?Python dist.Distribution怎么用?Python dist.Distribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.dist
的用法示例。
在下文中一共展示了dist.Distribution方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_dist_package_decoding_error
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_get_dist_package_decoding_error(self):
# Quiet stdout from distutils logs
stub_stdouts(self)
# trailing comma
package_json = '{"dependencies": {"left-pad": "~1.1.1"},}'
# bad data could be created by a competiting package.
mock_provider = MockProvider({
self.pkgname: package_json,
})
mock_dist = pkg_resources.Distribution(
metadata=mock_provider, project_name='dummydist', version='0.0.0')
results = calmjs_dist.read_dist_egginfo_json(mock_dist)
# Should still not fail.
self.assertIsNone(results)
示例2: test_build_calmjs_artifacts_standard
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_standard(self):
dist = distutils_dist.Distribution()
build_cmd = dist.get_command_obj('build')
original_subcmds = list(build_cmd.sub_commands)
calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', False)
self.assertEqual(original_subcmds, build_cmd.sub_commands)
# keys are named after the build step.
calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', True)
self.assertEqual(
('build_artifact', calmjs_dist.has_calmjs_artifact_declarations),
build_cmd.sub_commands[-1],
)
calmjs_dist.build_calmjs_artifacts(dist, 'calmjs_artifact', True)
self.assertEqual(
('calmjs_artifact', calmjs_dist.has_calmjs_artifact_declarations),
build_cmd.sub_commands[-1],
)
示例3: test_empty_options
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_empty_options(self):
# an empty options dictionary should not stay in the
# list of attributes
# catching warnings
warns = []
def _warn(msg):
warns.append(msg)
self.addCleanup(setattr, warnings, 'warn', warnings.warn)
warnings.warn = _warn
dist = Distribution(attrs={'author': 'xxx', 'name': 'xxx',
'version': 'xxx', 'url': 'xxxx',
'options': {}})
self.assertEqual(len(warns), 0)
self.assertNotIn('options', dir(dist))
示例4: test_empty_options
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_empty_options(self):
# an empty options dictionary should not stay in the
# list of attributes
klass = Distribution
# catching warnings
warns = []
def _warn(msg):
warns.append(msg)
old_warn = warnings.warn
warnings.warn = _warn
try:
dist = klass(attrs={'author': 'xxx',
'name': 'xxx',
'version': 'xxx',
'url': 'xxxx',
'options': {}})
finally:
warnings.warn = old_warn
self.assertEqual(len(warns), 0)
示例5: test_build_calmjs_artifacts_misconfigured
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_misconfigured(self):
dist = Distribution(attrs={
'name': 'some.package',
})
cmd = BuildArtifactCommand(dist=dist)
with self.assertRaises(DistutilsModuleError) as e:
cmd.run()
self.assertIn('artifact_builder is not callable for', str(e.exception))
示例6: test_build_calmjs_artifacts_dry_run
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_dry_run(self):
dist = Distribution(attrs={
'name': 'some.package',
'dry_run': True,
})
cmd = BuildArtifactCommand(dist=dist)
# usually this is defined in the subclass as a class attribute
cmd.artifact_builder = self.builder
cmd.run()
self.assertEqual([], self.built_names)
示例7: test_build_calmjs_artifacts_success
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_success(self):
dist = Distribution(attrs={
'name': 'some.package',
})
cmd = BuildArtifactCommand(dist=dist)
cmd.artifact_builder = self.builder
cmd.run()
self.assertEqual(['some.package'], self.built_names)
示例8: test_build_calmjs_artifacts_failure
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_failure(self):
dist = Distribution(attrs={
'name': 'fail.package',
})
cmd = BuildArtifactCommand(dist=dist)
cmd.artifact_builder = self.builder
with self.assertRaises(DistutilsModuleError) as e:
cmd.run()
# gets appended as an attempt
self.assertEqual(['fail.package'], self.built_names)
self.assertIn(
"some entries in registry 'demo.artifacts' defined for package "
"'fail.package' failed to generate an artifact", str(e.exception),
)
示例9: setUp
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def setUp(self):
self.dist = Distribution()
self.optname = 'default_json'
self.pkgname = calmjs_dist.DEFAULT_JSON
示例10: test_read_dist_egginfo_json
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_read_dist_egginfo_json(self):
package_json = {"dependencies": {"left-pad": "~1.1.1"}}
# We will mock up a Distribution object with some fake metadata.
mock_provider = MockProvider({
self.pkgname: json.dumps(package_json),
})
mock_dist = pkg_resources.Distribution(
metadata=mock_provider, project_name='dummydist', version='0.0.0')
results = calmjs_dist.read_dist_egginfo_json(mock_dist)
self.assertEqual(results, package_json)
示例11: test_get_dist_package_read_error
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_get_dist_package_read_error(self):
# Quiet stdout from distutils logs
stub_stdouts(self)
mock_provider = MockProvider({
self.pkgname: None, # None will emulate IO error.
})
mock_dist = pkg_resources.Distribution(
metadata=mock_provider, project_name='dummydist', version='0.0.0')
results = calmjs_dist.read_dist_egginfo_json(mock_dist)
# Should still not fail.
self.assertIsNone(results)
示例12: test_read_dist_egginfo_json_alternative_name_args
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_read_dist_egginfo_json_alternative_name_args(self):
package_json = {"dependencies": {"left-pad": "~1.1.1"}}
# We will mock up a Distribution object with some fake metadata.
mock_provider = MockProvider({
'bower.json': json.dumps(package_json),
})
mock_dist = pkg_resources.Distribution(
metadata=mock_provider, project_name='dummydist', version='0.0.0')
results = calmjs_dist.read_dist_egginfo_json(
mock_dist, filename='bower.json')
self.assertEqual(results, package_json)
working_set = pkg_resources.WorkingSet()
working_set.add(mock_dist)
self.assertEqual(package_json, calmjs_dist.read_egginfo_json(
'dummydist', filename='bower.json', working_set=working_set))
# Finally do the flattening
flattened_json = {
"dependencies": {"left-pad": "~1.1.1"}, "devDependencies": {}}
self.assertEqual(flattened_json, calmjs_dist.flatten_dist_egginfo_json(
[mock_dist], filename='bower.json', working_set=working_set))
self.assertEqual(flattened_json, calmjs_dist.flatten_egginfo_json(
['dummydist'], filename='bower.json', working_set=working_set))
示例13: test_read_dist_line_list
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_read_dist_line_list(self):
# We will mock up a Distribution object with some fake metadata.
mock_provider = MockProvider({
'list.txt': 'reg1\nreg2',
})
mock_dist = pkg_resources.Distribution(
metadata=mock_provider, project_name='dummydist', version='0.0.0')
results = calmjs_dist.read_dist_line_list(mock_dist, 'list.txt')
self.assertEqual(results, ['reg1', 'reg2'])
示例14: test_calmjs_artifact_declarations
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_calmjs_artifact_declarations(self):
from calmjs.registry import _inst
# the actual implementations this is supporting
from calmjs.artifact import build_calmjs_artifacts
from calmjs.artifact import ArtifactRegistry
working_dir = mkdtemp(self)
make_dummy_dist(self, (
('entry_points.txt', '\n'.join([
'[calmjs.registry]',
'calmjs.artifacts = calmjs.artifact:ArtifactsRegistry',
])),
), 'calmjs', '1.0', working_dir=working_dir)
make_dummy_dist(self, (
('entry_points.txt', '\n'.join([
'[calmjs.artifacts]',
'example.js = example:builder',
])),
), 'some.package', '1.0', working_dir=working_dir)
mock_ws = pkg_resources.WorkingSet([working_dir])
registry_id = 'calmjs.artifacts'
registry = ArtifactRegistry(registry_id, _working_set=mock_ws)
# cleanup the about to be injected version.
self.addCleanup(_inst.records.pop, registry_id, None)
_inst.records['calmjs.artifacts'] = registry
# construct a command for the declaration check.
cmd = build_calmjs_artifacts(dist=distutils_dist.Distribution(
attrs={'name': 'some.package'}))
self.assertTrue(calmjs_dist.has_calmjs_artifact_declarations(cmd))
cmd = build_calmjs_artifacts(dist=distutils_dist.Distribution(
attrs={'name': 'missing.package'}))
self.assertFalse(calmjs_dist.has_calmjs_artifact_declarations(cmd))
cmd = build_calmjs_artifacts(dist=distutils_dist.Distribution(
attrs={'name': 'calmjs'}))
self.assertFalse(calmjs_dist.has_calmjs_artifact_declarations(cmd))
示例15: test_build_calmjs_artifacts_failure
# 需要导入模块: from distutils import dist [as 别名]
# 或者: from distutils.dist import Distribution [as 别名]
def test_build_calmjs_artifacts_failure(self):
def fakecmd(*a, **kw):
return object
dist = distutils_dist.Distribution(attrs={
'cmdclass': {'build': fakecmd},
})
with pretty_logging(stream=StringIO()) as stream:
calmjs_dist.build_calmjs_artifacts(dist, 'build_again', True)
self.assertIn(
"'build' command in Distribution is not an instance of "
"'distutils.command.build:build'", stream.getvalue(),
)