本文整理汇总了Python中test.test_support.TESTFN_UNICODE属性的典型用法代码示例。如果您正苦于以下问题:Python test_support.TESTFN_UNICODE属性的具体用法?Python test_support.TESTFN_UNICODE怎么用?Python test_support.TESTFN_UNICODE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类test.test_support
的用法示例。
在下文中一共展示了test_support.TESTFN_UNICODE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_path_with_null_unicode
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import TESTFN_UNICODE [as 别名]
def test_path_with_null_unicode(self):
fn = test_support.TESTFN_UNICODE
try:
fn.encode(test_support.TESTFN_ENCODING)
except (UnicodeError, TypeError):
self.skipTest("Requires unicode filenames support")
fn_with_NUL = fn + u'\0'
self.addCleanup(test_support.unlink, fn)
test_support.unlink(fn)
fd = None
try:
with self.assertRaises(TypeError):
fd = os.open(fn_with_NUL, os.O_WRONLY | os.O_CREAT) # raises
finally:
if fd is not None:
os.close(fd)
self.assertFalse(os.path.exists(fn))
self.assertRaises(TypeError, os.mkdir, fn_with_NUL)
self.assertFalse(os.path.exists(fn))
open(fn, 'wb').close()
self.assertRaises(TypeError, os.stat, fn_with_NUL)
示例2: test_expat_locator_withinfo_unicode
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import TESTFN_UNICODE [as 别名]
def test_expat_locator_withinfo_unicode(self):
fname = support.TESTFN_UNICODE
shutil.copyfile(TEST_XMLFILE, fname)
self.addCleanup(support.unlink, fname)
result = StringIO()
xmlgen = XMLGenerator(result)
parser = create_parser()
parser.setContentHandler(xmlgen)
parser.parse(fname)
self.assertEqual(parser.getSystemId(), fname)
self.assertEqual(parser.getPublicId(), None)
# ===========================================================================
#
# error reporting
#
# ===========================================================================
示例3: test_unicode_filename
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import TESTFN_UNICODE [as 别名]
def test_unicode_filename(self):
unicode_filename = test_support.TESTFN_UNICODE
try:
unicode_filename.encode(test_support.TESTFN_ENCODING)
except (UnicodeError, TypeError):
self.skipTest("Requires unicode filenames support")
self.filename = unicode_filename
with gzip.GzipFile(unicode_filename, "wb") as f:
f.write(data1 * 50)
with gzip.GzipFile(unicode_filename, "rb") as f:
self.assertEqual(f.read(), data1 * 50)
# Sanity check that we are actually operating on the right file.
with open(unicode_filename, 'rb') as fobj, \
gzip.GzipFile(fileobj=fobj, mode="rb") as f:
self.assertEqual(f.read(), data1 * 50)
示例4: test_expat_file_unicode
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import TESTFN_UNICODE [as 别名]
def test_expat_file_unicode(self):
fname = support.TESTFN_UNICODE
shutil.copyfile(TEST_XMLFILE, fname)
self.addCleanup(support.unlink, fname)
parser = create_parser()
result = StringIO()
xmlgen = XMLGenerator(result)
parser.setContentHandler(xmlgen)
parser.parse(open(fname))
self.assertEqual(result.getvalue(), xml_test_out)
# ===== DTDHandler support
示例5: test_expat_inpsource_sysid_unicode
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import TESTFN_UNICODE [as 别名]
def test_expat_inpsource_sysid_unicode(self):
fname = support.TESTFN_UNICODE
shutil.copyfile(TEST_XMLFILE, fname)
self.addCleanup(support.unlink, fname)
parser = create_parser()
result = StringIO()
xmlgen = XMLGenerator(result)
parser.setContentHandler(xmlgen)
parser.parse(InputSource(fname))
self.assertEqual(result.getvalue(), xml_test_out)
示例6: test_unicode_filename
# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import TESTFN_UNICODE [as 别名]
def test_unicode_filename(self):
unicode_filename = test_support.TESTFN_UNICODE
try:
unicode_filename.encode(test_support.TESTFN_ENCODING)
except (UnicodeError, TypeError):
self.skipTest("Requires unicode filenames support")
with gzip.GzipFile(unicode_filename, "wb") as f:
f.write(data1 * 50)
with gzip.GzipFile(unicode_filename, "rb") as f:
self.assertEqual(f.read(), data1 * 50)
# Sanity check that we are actually operating on the right file.
with open(unicode_filename, 'rb') as fobj, \
gzip.GzipFile(fileobj=fobj, mode="rb") as f:
self.assertEqual(f.read(), data1 * 50)