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


Python StringIO.getvalue方法代码示例

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


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

示例1: test_spelling

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_spelling(self):
     status = StringIO()
     with TemporaryDirectory() as OUT_DIR:
         with tmp_list_append(sys.argv, 'spelling'):
             try:
                 app = Sphinx(
                     srcdir=DOCS_DIR,
                     confdir=DOCS_DIR,
                     outdir=OUT_DIR,
                     doctreedir=OUT_DIR,
                     buildername="spelling",
                     warningiserror=True,
                     status=status,
                     confoverrides={
                         'extensions': [
                             'djangocms',
                             'sphinx.ext.intersphinx',
                             'sphinxcontrib.spelling'
                         ]
                     }
                 )
                 app.build()
                 self.assertEqual(app.statuscode, 0, status.getvalue())
             except SphinxWarning:
                 # while normally harmless, causes a test failure
                 pass
             except:
                 print(status.getvalue())
                 raise
开发者ID:quanpower,项目名称:django-cms,代码行数:31,代码来源:test_docs.py

示例2: test_dsn_full

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
    def test_dsn_full(self):
        out = StringIO()
        err = StringIO()
        call_command("dbparams", "default", dsn=True, stdout=out, stderr=err, skip_checks=True)
        output = out.getvalue()
        assert output == "F=/tmp/defaults.cnf,u=ausername,p=apassword,h=ahost.example.com," "P=12345,D=mydatabase"

        errors = err.getvalue()
        assert "SSL params can't be" in errors
开发者ID:ezc,项目名称:django-mysql,代码行数:11,代码来源:test_dbparams.py

示例3: test_dsn_socket

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
    def test_dsn_socket(self):
        out = StringIO()
        err = StringIO()
        call_command("dbparams", dsn=True, stdout=out, stderr=err, skip_checks=True)

        output = out.getvalue()
        assert output == "S=/etc/mydb.sock"

        errors = err.getvalue()
        assert errors == ""
开发者ID:ezc,项目名称:django-mysql,代码行数:12,代码来源:test_dbparams.py

示例4: test_dsn_socket

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
    def test_dsn_socket(self):
        out = StringIO()
        err = StringIO()
        call_command('dbparams', dsn=True, stdout=out, stderr=err)

        output = out.getvalue()
        self.assertEqual(output, 'S=/etc/mydb.sock')

        errors = err.getvalue()
        self.assertEqual(errors, "")
开发者ID:adamyp,项目名称:django-mysql,代码行数:12,代码来源:test_management.py

示例5: test_dsn_full

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
    def test_dsn_full(self):
        out = StringIO()
        err = StringIO()
        call_command('dbparams', 'default', dsn=True, stdout=out, stderr=err)
        output = out.getvalue()
        self.assertEqual(
            output,
            "F=/tmp/defaults.cnf,u=ausername,p=apassword,h=ahost.example.com,"
            "P=12345,D=mydatabase"
        )

        errors = err.getvalue()
        self.assertIn("SSL params can't be", errors)
开发者ID:adamyp,项目名称:django-mysql,代码行数:15,代码来源:test_management.py

示例6: test_mysql_cache_migration_alias

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
    def test_mysql_cache_migration_alias(self):
        out = StringIO()
        call_command('mysql_cache_migration', 'default', stdout=out)
        output = out.getvalue()

        num_run_sqls = (len(output.split('RunSQL')) - 1)
        assert num_run_sqls == 1
开发者ID:VladimirKuzmin,项目名称:django-mysql,代码行数:9,代码来源:test_cache.py

示例7: render

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
    def render(self, data, *args, **kwargs):
        charset = 'utf-8'
        root_node = 'xforms'
        xmlns = "http://openrosa.org/xforms/xformsList"

        if 'detail' in data.keys():
            stream = StringIO()

            xml = SimplerXMLGenerator(stream, charset)
            xml.startDocument()
            xml.startElement(root_node, {'xmlns': xmlns})

            for key, value in six.iteritems(data):
                xml.startElement(key, {})
                xml.characters(smart_text(value))
                xml.endElement(key)

            xml.endElement(root_node)
            xml.endDocument()
            return stream.getvalue()
        else:
            json = self.transform_to_xform_json(data)
            survey = create_survey_element_from_dict(json)
            xml = survey.xml()
            fix_languages(xml)
            xml = xml.toxml()

            xml = self.insert_version_attribute(xml,
                                                data.get('id_string'),
                                                data.get('version'))
            xml = self.insert_uuid_bind(xml, data.get('id_string'))

            return xml
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:35,代码来源:renderers.py

示例8: test_list_apphooks

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_list_apphooks(self):
     out = StringIO()
     create_page('Hello Title', "nav_playground.html", "en", apphook=APPHOOK)
     self.assertEqual(Page.objects.filter(application_urls=APPHOOK).count(), 1)
     command = cms.Command()
     command.stdout = out
     command.handle("list", "apphooks", interactive=False)
     self.assertEqual(out.getvalue(), "SampleApp\n")
开发者ID:AllenYang0308,项目名称:django-cms,代码行数:10,代码来源:management.py

示例9: test_uninstall_plugins_with_plugin

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_uninstall_plugins_with_plugin(self):
     out = StringIO()
     placeholder = Placeholder.objects.create(slot="test")
     add_plugin(placeholder, TextPlugin, "en", body="en body")
     self.assertEqual(CMSPlugin.objects.filter(plugin_type=PLUGIN).count(), 1)
     management.call_command('cms', 'uninstall', 'plugins', PLUGIN, interactive=False, stdout=out)
     self.assertEqual(out.getvalue(), "1 'TextPlugin' plugins uninstalled\n")
     self.assertEqual(CMSPlugin.objects.filter(plugin_type=PLUGIN).count(), 0)
开发者ID:evildmp,项目名称:django-cms,代码行数:10,代码来源:test_management.py

示例10: test_mysql_full

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_mysql_full(self):
     out = StringIO()
     call_command("dbparams", stdout=out, skip_checks=True)
     output = out.getvalue()
     assert (
         output == "--defaults-file=/tmp/defaults.cnf --user=ausername "
         "--password=apassword --host=ahost.example.com --port=12345 "
         "--ssl-ca=/tmp/mysql.cert mydatabase"
     )
开发者ID:ezc,项目名称:django-mysql,代码行数:11,代码来源:test_dbparams.py

示例11: test_uninstall_apphooks_with_apphook

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_uninstall_apphooks_with_apphook(self):
     out = StringIO()
     create_page('Hello Title', "nav_playground.html", "en", apphook=APPHOOK)
     self.assertEqual(Page.objects.filter(application_urls=APPHOOK).count(), 1)
     command = cms.Command()
     command.stdout = out
     command.handle("uninstall", "apphooks", APPHOOK, interactive=False)
     self.assertEqual(out.getvalue(), "1 'SampleApp' apphooks uninstalled\n")
     self.assertEqual(Page.objects.filter(application_urls=APPHOOK).count(), 0)
开发者ID:AllenYang0308,项目名称:django-cms,代码行数:11,代码来源:management.py

示例12: test_uninstall_plugins_with_plugin

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_uninstall_plugins_with_plugin(self):
     out = StringIO()
     placeholder = Placeholder.objects.create(slot="test")
     add_plugin(placeholder, TextPlugin, "en", body="en body")
     self.assertEqual(CMSPlugin.objects.filter(plugin_type=PLUGIN).count(), 1)
     command = cms.Command()
     command.stdout = out
     command.handle("uninstall", "plugins", PLUGIN, interactive=False)
     self.assertEqual(out.getvalue(), "1 'TextPlugin' plugins uninstalled\n")
     self.assertEqual(CMSPlugin.objects.filter(plugin_type=PLUGIN).count(), 0)
开发者ID:AllenYang0308,项目名称:django-cms,代码行数:12,代码来源:management.py

示例13: _exception_traceback

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
def _exception_traceback(exc_info):
    """
    Return a string containing a traceback message for the given
    exc_info tuple (as returned by sys.exc_info()).
    """
    # Get a traceback message.
    excout = StringIO()
    exc_type, exc_val, exc_tb = exc_info
    traceback.print_exception(exc_type, exc_val, exc_tb, file=excout)
    return excout.getvalue()
开发者ID:,项目名称:,代码行数:12,代码来源:

示例14: test_mysql_full

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_mysql_full(self):
     out = StringIO()
     call_command('dbparams', stdout=out)
     output = out.getvalue()
     self.assertEqual(
         output,
         "--defaults-file=/tmp/defaults.cnf --user=ausername "
         "--password=apassword --host=ahost.example.com --port=12345 "
         "--ssl-ca=/tmp/mysql.cert mydatabase"
     )
开发者ID:adamyp,项目名称:django-mysql,代码行数:12,代码来源:test_management.py

示例15: test_list_apphooks

# 需要导入模块: from django.utils.six.moves import StringIO [as 别名]
# 或者: from django.utils.six.moves.StringIO import getvalue [as 别名]
 def test_list_apphooks(self):
     out = StringIO()
     apps = ["cms", "menus", "sekizai", "cms.test_utils.project.sampleapp"]
     with SettingsOverride(INSTALLED_APPS=apps):
         create_page('Hello Title', "nav_playground.html", "en", apphook=APPHOOK)
         self.assertEqual(Page.objects.filter(application_urls=APPHOOK).count(), 1)
         command = cms.Command()
         command.stdout = out
         command.handle("list", "apphooks", interactive=False)
         self.assertEqual(out.getvalue(), "SampleApp\n")
开发者ID:1oscar,项目名称:django-cms,代码行数:12,代码来源:management.py


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