예제 #1
0
 def skip_if_cannot_represent_filename(self, u):
     enc = get_filesystem_encoding()
     if not unicode_platform():
         try:
             u.encode(enc)
         except UnicodeEncodeError:
             raise unittest.SkipTest("A non-ASCII filename could not be encoded on this platform.")
예제 #2
0
 def skip_if_cannot_represent_filename(self, u):
     enc = get_filesystem_encoding()
     if not unicode_platform():
         try:
             u.encode(enc)
         except UnicodeEncodeError:
             raise unittest.SkipTest("A non-ASCII filename could not be encoded on this platform.")
예제 #3
0
 def unicode_or_fallback(self, unicode_name, fallback_name):
     if unicode_platform():
         return unicode_name
     try:
         unicode_name.encode(get_filesystem_encoding())
         return unicode_name
     except UnicodeEncodeError:
         return fallback_name
예제 #4
0
 def unicode_or_fallback(self, unicode_name, fallback_name):
     if unicode_platform():
         return unicode_name
     try:
         unicode_name.encode(get_filesystem_encoding())
         return unicode_name
     except UnicodeEncodeError:
         return fallback_name
예제 #5
0
    def test_unicode_platform(self):
        matrix = {
          'linux2': False,
          'openbsd4': False,
          'win32':  True,
          'darwin': True,
        }

        _reload()
        self.failUnlessReallyEqual(unicode_platform(), matrix[self.platform])
예제 #6
0
    def test_unicode_platform(self):
        matrix = {
            'linux2': False,
            'openbsd4': False,
            'win32': True,
            'darwin': True,
        }

        _reload()
        self.failUnlessReallyEqual(unicode_platform(), matrix[self.platform])
예제 #7
0
    def test_open_unrepresentable(self):
        if unicode_platform():
            raise unittest.SkipTest("This test is not applicable to platforms that represent filenames as Unicode.")

        enc = get_filesystem_encoding()
        fn = u'\u2621.txt'
        try:
            fn.encode(enc)
            raise unittest.SkipTest("This test cannot be run unless we know a filename that is not representable.")
        except UnicodeEncodeError:
            self.failUnlessRaises(UnicodeEncodeError, open, fn, 'wb')
예제 #8
0
    def test_open_unrepresentable(self):
        if unicode_platform():
            raise unittest.SkipTest("This test is not applicable to platforms that represent filenames as Unicode.")

        enc = get_filesystem_encoding()
        fn = u'\u2621.txt'
        try:
            fn.encode(enc)
            raise unittest.SkipTest("This test cannot be run unless we know a filename that is not representable.")
        except UnicodeEncodeError:
            self.failUnlessRaises(UnicodeEncodeError, open, fn, 'wb')
예제 #9
0
    def unicode_or_fallback(self, unicode_name, fallback_name, io_as_well=False):
        if not unicode_platform():
            try:
                unicode_name.encode(get_filesystem_encoding())
            except UnicodeEncodeError:
                return fallback_name

        if io_as_well:
            try:
                unicode_name.encode(get_io_encoding())
            except UnicodeEncodeError:
                return fallback_name

        return unicode_name
예제 #10
0
    def unicode_or_fallback(self, unicode_name, fallback_name, io_as_well=False):
        if not unicode_platform():
            try:
                unicode_name.encode(get_filesystem_encoding())
            except UnicodeEncodeError:
                return fallback_name

        if io_as_well:
            try:
                unicode_name.encode(get_io_encoding())
            except UnicodeEncodeError:
                return fallback_name

        return unicode_name
예제 #11
0
 def test_unicode_platform_py3(self):
     _reload()
     self.failUnlessReallyEqual(unicode_platform(), True)
예제 #12
0
    def test_unicode_platform(self):
        matrix = {"linux2": False, "linux3": False, "openbsd4": False, "win32": True, "darwin": True}

        _reload()
        self.failUnlessReallyEqual(unicode_platform(), matrix[self.platform])