當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。