File: test_unicode.py

package info (click to toggle)
pydicom 0.9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,752 kB
  • ctags: 961
  • sloc: python: 23,351; makefile: 83; sh: 13
file content (31 lines) | stat: -rw-r--r-- 834 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# test_unicode.py
# -*- coding: utf-8 -*-

import dicom
import sys
import unittest


class UnicodeFilenames(unittest.TestCase):
    def testRead(self):
        """Unicode: Can read a file with unicode characters in name................"""
        uni_name = u'test°'

        # verify first that we could encode file name in this environment
        try:
            _ = uni_name.encode(sys.getfilesystemencoding())
        except UnicodeEncodeError:
            print("SKIP: Environment doesn't support unicode filenames")
            return

        try:
            dicom.read_file(uni_name)
        except UnicodeEncodeError:
            self.fail("UnicodeEncodeError generated for unicode name")
        # ignore file doesn't exist error
        except IOError:
            pass


if __name__ == "__main__":
    unittest.main()