当前位置: 首页>>代码示例>>Python>>正文


Python dist.Distribution方法代码示例

本文整理汇总了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) 
开发者ID:calmjs,项目名称:calmjs,代码行数:19,代码来源:test_dist.py

示例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],
        ) 
开发者ID:calmjs,项目名称:calmjs,代码行数:21,代码来源:test_dist.py

示例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)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:20,代码来源:test_dist.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:24,代码来源:test_dist.py

示例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)) 
开发者ID:calmjs,项目名称:calmjs,代码行数:11,代码来源:test_command.py

示例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) 
开发者ID:calmjs,项目名称:calmjs,代码行数:12,代码来源:test_command.py

示例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) 
开发者ID:calmjs,项目名称:calmjs,代码行数:10,代码来源:test_command.py

示例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),
        ) 
开发者ID:calmjs,项目名称:calmjs,代码行数:16,代码来源:test_command.py

示例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 
开发者ID:calmjs,项目名称:calmjs,代码行数:6,代码来源:test_dist.py

示例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) 
开发者ID:calmjs,项目名称:calmjs,代码行数:16,代码来源:test_dist.py

示例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) 
开发者ID:calmjs,项目名称:calmjs,代码行数:14,代码来源:test_dist.py

示例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)) 
开发者ID:calmjs,项目名称:calmjs,代码行数:31,代码来源:test_dist.py

示例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']) 
开发者ID:calmjs,项目名称:calmjs,代码行数:11,代码来源:test_dist.py

示例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)) 
开发者ID:calmjs,项目名称:calmjs,代码行数:43,代码来源:test_dist.py

示例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(),
        ) 
开发者ID:calmjs,项目名称:calmjs,代码行数:17,代码来源:test_dist.py


注:本文中的distutils.dist.Distribution方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。