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


Python content.text_content方法代码示例

本文整理汇总了Python中testtools.content.text_content方法的典型用法代码示例。如果您正苦于以下问题:Python content.text_content方法的具体用法?Python content.text_content怎么用?Python content.text_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testtools.content的用法示例。


在下文中一共展示了content.text_content方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_command_hooks

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_command_hooks(self):
        """Test command hooks.

        Simple test that the appropriate command hooks run at the
        beginning/end of the appropriate command.
        """

        stdout, _, return_code = self.run_setup('egg_info')
        assert 'build_ext pre-hook' not in stdout
        assert 'build_ext post-hook' not in stdout
        assert return_code == 0

        stdout, stderr, return_code = self.run_setup('build_ext')
        self.addDetailUniqueName('stderr', text_content(stderr))
        assert textwrap.dedent("""
            running build_ext
            running pre_hook pbr_testpackage._setup_hooks.test_pre_hook for command build_ext
            build_ext pre-hook
        """) in stdout  # flake8: noqa
        self.expectThat(stdout, EndsWith('build_ext post-hook'))
        assert return_code == 0 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:23,代码来源:test_hooks.py

示例2: test_volume_to_image

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_volume_to_image(self):
        '''Test volume export to image functionality'''
        volume_name = self.getUniqueString()
        image_name = self.getUniqueString()
        self.addDetail('volume', content.text_content(volume_name))
        self.addCleanup(self.cleanup, volume_name, image_name=image_name)
        volume = self.user_cloud.create_volume(
            display_name=volume_name, size=1)
        image = self.user_cloud.create_image(
            image_name, volume=volume, wait=True)

        volume_ids = [v['id'] for v in self.user_cloud.list_volumes()]
        self.assertIn(volume['id'], volume_ids)

        image_list = self.user_cloud.list_images()
        image_ids = [s['id'] for s in image_list]
        self.assertIn(image['id'], image_ids)

        self.user_cloud.delete_image(image_name, wait=True)
        self.user_cloud.delete_volume(volume_name, wait=True) 
开发者ID:openstack,项目名称:openstacksdk,代码行数:22,代码来源:test_volume.py

示例3: test_staged_file

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_staged_file(self):
        # Prove that we can get a file we have staged.
        # Start with a standard commit and tag
        self._make_python_package()
        self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
        # Now stage a release note
        n = self.get_note_num()
        basename = 'staged-note-%016x.yaml' % n
        filename = os.path.join(self.reporoot, 'releasenotes', 'notes',
                                basename)
        create._make_note_file(filename, 'staged note')
        self.repo.git('add', filename)
        status_results = self.repo.git('status')
        self.addDetail('git status', text_content(status_results))
        # Now run the scanner
        self.scanner = scanner.Scanner(self.c)
        raw_results = self.scanner.get_notes_by_version()
        self.assertEqual(
            {'*working-copy*': [
                (os.path.join('releasenotes', 'notes', basename),
                 None)],
             },
            raw_results,
        ) 
开发者ID:openstack,项目名称:reno,代码行数:26,代码来源:test_scanner.py

示例4: test_added_tagged_not_staged

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_added_tagged_not_staged(self):
        # Prove that we can get a file we have created but not staged.
        # Start with a standard commit and tag
        self._make_python_package()
        self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
        # Now create a note without staging it
        n = self.get_note_num()
        basename = 'staged-note-%016x.yaml' % n
        filename = os.path.join(self.reporoot, 'releasenotes', 'notes',
                                basename)
        create._make_note_file(filename, 'staged note')
        status_results = self.repo.git('status')
        self.addDetail('git status', text_content(status_results))
        # Now run the scanner
        self.scanner = scanner.Scanner(self.c)
        raw_results = self.scanner.get_notes_by_version()
        # Take the staged version of the file, but associate it with
        # tagged version 1.0.0 because the file was added before that
        # version.
        self.assertEqual(
            {'1.0.0': [(os.path.join('releasenotes', 'notes', basename),
                        None)],
             },
            raw_results,
        ) 
开发者ID:openstack,项目名称:reno,代码行数:27,代码来源:test_scanner.py

示例5: test_modified_tagged_not_staged

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_modified_tagged_not_staged(self):
        # Prove that we can get a file we have changed but not staged.
        # Start with a standard commit and tag
        self._make_python_package()
        f1 = self._add_notes_file('slug1')
        self.repo.git('tag', '-s', '-m', 'first tag', '1.0.0')
        # Now modify the note
        fullpath = os.path.join(self.repo.reporoot, f1)
        with open(fullpath, 'w') as f:
            f.write('modified first note')
        status_results = self.repo.git('status')
        self.addDetail('git status', text_content(status_results))
        # Now run the scanner
        self.scanner = scanner.Scanner(self.c)
        raw_results = self.scanner.get_notes_by_version()
        # Take the staged version of the file, but associate it with
        # tagged version 1.0.0 because the file was added before that
        # version.
        self.assertEqual(
            {'1.0.0': [(f1, None)],
             },
            raw_results,
        ) 
开发者ID:openstack,项目名称:reno,代码行数:25,代码来源:test_scanner.py

示例6: test_files_current_branch

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_files_current_branch(self):
        self.repo.git('checkout', '2.0.0')
        self.repo.git('checkout', '-b', 'stable/2')
        f21 = self._add_notes_file('slug21')
        log_text = self.repo.git('log', '--decorate')
        self.addDetail('git log', text_content(log_text))
        self.scanner = scanner.Scanner(self.c)
        raw_results = self.scanner.get_notes_by_version()
        results = {
            k: [f for (f, n) in v]
            for (k, v) in raw_results.items()
        }
        self.assertEqual(
            {
                '2.0.0-1': [f21],
                '2.0.0': [self.f2],
            },
            results,
        ) 
开发者ID:openstack,项目名称:reno,代码行数:21,代码来源:test_scanner.py

示例7: test_twistd_low_verbosity

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_twistd_low_verbosity(self):
        verbosity, set_verbosity = self._get_log_levels(1)
        name = factory.make_name("log.name")
        logged = log_something(
            name,
            verbosity=verbosity,
            set_verbosity=set_verbosity,
            mode=LoggingMode.TWISTD,
        )
        self.addDetail("logged", text_content(logged))
        observed = find_log_lines(logged)
        expected = [
            (name, "warn", "From `twisted.logger`."),
            (name, "error", "From `twisted.logger`."),
            (name, "warn", "From `logging`."),
            (name, "error", "From `logging`."),
            ("maas." + name, "warn", "From `get_maas_logger`."),
            ("maas." + name, "error", "From `get_maas_logger`."),
            ("stderr", "error", "Printing to stderr."),
            ("-", "warn", "UserWarning: This is a warning!"),
        ]
        self.assertSequenceEqual(expected, observed) 
开发者ID:maas,项目名称:maas,代码行数:24,代码来源:test_logger.py

示例8: test_twistd_lowest_verbosity

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_twistd_lowest_verbosity(self):
        verbosity, set_verbosity = self._get_log_levels(0)
        name = factory.make_name("log.name")
        logged = log_something(
            name,
            verbosity=verbosity,
            set_verbosity=set_verbosity,
            mode=LoggingMode.TWISTD,
        )
        self.addDetail("logged", text_content(logged))
        observed = find_log_lines(logged)
        expected = [
            (name, "error", "From `twisted.logger`."),
            (name, "error", "From `logging`."),
            ("maas." + name, "error", "From `get_maas_logger`."),
            ("stderr", "error", "Printing to stderr."),
        ]
        self.assertSequenceEqual(expected, observed) 
开发者ID:maas,项目名称:maas,代码行数:20,代码来源:test_logger.py

示例9: get_details

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def get_details(self):
        return {
            'expected': content.text_content(self.expected),
            'actual': content.text_content(self.actual),
        } 
开发者ID:openstack,项目名称:ec2-api,代码行数:7,代码来源:matchers.py

示例10: setUp

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def setUp(self):
        super(CapturedSubprocess, self).setUp()
        proc = subprocess.Popen(*self.args, **self.kwargs)
        out, err = proc.communicate()
        self.out = out.decode('utf-8', 'replace')
        self.err = err.decode('utf-8', 'replace')
        self.addDetail(self.label + '-stdout', content.text_content(self.out))
        self.addDetail(self.label + '-stderr', content.text_content(self.err))
        self.returncode = proc.returncode
        if proc.returncode:
            raise AssertionError('Failed process %s' % proc.returncode)
        self.addCleanup(delattr, self, 'out')
        self.addCleanup(delattr, self, 'err')
        self.addCleanup(delattr, self, 'returncode') 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:16,代码来源:base.py

示例11: test_custom_build_py_command

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_custom_build_py_command(self):
        """Test custom build_py command.

        Test that a custom subclass of the build_py command runs when listed in
        the commands [global] option, rather than the normal build command.
        """

        stdout, stderr, return_code = self.run_setup('build_py')
        self.addDetail('stdout', content.text_content(stdout))
        self.addDetail('stderr', content.text_content(stderr))
        self.assertIn('Running custom build_py command.', stdout)
        self.assertEqual(return_code, 0) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:14,代码来源:test_commands.py

示例12: test_custom_rpm_version_py_command

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_custom_rpm_version_py_command(self):
        """Test custom rpm_version command."""
        stdout, stderr, return_code = self.run_setup('rpm_version')
        self.addDetail('stdout', content.text_content(stdout))
        self.addDetail('stderr', content.text_content(stderr))
        self.assertIn('Extracting rpm version', stdout)
        self.assertEqual(return_code, 0) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:9,代码来源:test_commands.py

示例13: test_template_error

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def test_template_error(self):
        """
        Template errors result in the process exiting and an error message
        printed to stderr.
        Packer prints machine-readable output to stderr and
        ``publish-installer-images`` echos those lines to its stderr as well as
        parsing the output.
        """
        sys_module = FakeSysModule()
        self.addCleanup(
            lambda: self.addDetail(
                name="stderr",
                content_object=text_content(
                    sys_module.stderr.getvalue()
                )
            )
        )

        configuration_path = self.make_temporary_file(content='')

        d = async_perform(
            dispatcher=RealPerformers(
                sys_module=sys_module,
            ).dispatcher(),
            effect=Effect(
                intent=PackerBuild(
                    configuration_path=configuration_path,
                )
            )
        )

        d = self.assertFailure(d, ProcessTerminated)

        def check_error(exception):
            self.assertEqual(1, exception.exitCode)
            self.assertIn(
                "Failed to parse template", sys_module.stderr.getvalue()
            )
        return d.addCallback(check_error) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:41,代码来源:test_images.py

示例14: _test_skipped

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def _test_skipped(case, result, exception):
    result.addSkip(case, details={'reason': text_content(unicode(exception))}) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:4,代码来源:_base.py

示例15: _attempt_test

# 需要导入模块: from testtools import content [as 别名]
# 或者: from testtools.content import text_content [as 别名]
def _attempt_test(self, case):
        """
        Run 'case' with a temporary result.

        :param testtools.TestCase case: The test to run.

        :return: a tuple of ``(successful, result, details)``, where
            ``successful`` is a boolean indicating whether the test was
            succcessful, ``result`` is a _ResultType indicating what the test
            result was and ``details`` is a dictionary of testtools details.
        """
        tmp_result = testtools.TestResult()
        # XXX: Still using internal API of testtools despite improvements in
        # #165. Will need to do follow-up work on testtools to ensure that
        # RunTest.run(case); RunTest.run(case) is supported.
        case._reset()
        self._run_test(case, tmp_result)
        result_type = _get_result_type(tmp_result)
        details = pmap(case.getDetails())
        if result_type == _ResultType.skip:
            # XXX: Work around a testtools bug where it reports stack traces
            # for skips that aren't passed through its supported
            # SkipException: https://bugs.launchpad.net/testtools/+bug/1518100
            [reason] = list(tmp_result.skip_reasons.keys())
            details = details.discard('traceback').set(
                'reason', text_content(reason))
        return (tmp_result.wasSuccessful(), result_type, details) 
开发者ID:ClusterHQ,项目名称:flocker,代码行数:29,代码来源:_flaky.py


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