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


Python test_support.TESTFN_UNICODE属性代码示例

本文整理汇总了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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_posix.py

示例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
#
# =========================================================================== 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:test_sax.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_gzip.py

示例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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:test_sax.py

示例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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_sax.py

示例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) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:16,代码来源:test_gzip.py


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