本文整理汇总了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
示例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
示例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 == ""
示例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, "")
示例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)
示例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
示例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
示例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")
示例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)
示例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"
)
示例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)
示例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)
示例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()
示例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"
)
示例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")