| 599 | @unittest.skipIf(sys.getfilesystemencoding() != 'utf-8', |
| 600 | "test only works for utf-8 filesystems") |
| 601 | def testUtf8BytesOpen(self): |
| 602 | # Opening a UTF-8 bytes filename |
| 603 | try: |
| 604 | fn = TESTFN_UNICODE.encode("utf-8") |
| 605 | except UnicodeEncodeError: |
| 606 | self.skipTest('could not encode %r to utf-8' % TESTFN_UNICODE) |
| 607 | f = self.FileIO(fn, "w") |
| 608 | try: |
| 609 | f.write(b"abc") |
| 610 | f.close() |
| 611 | with self.open(TESTFN_UNICODE, "rb") as f: |
| 612 | self.assertEqual(f.read(), b"abc") |
| 613 | finally: |
| 614 | os.unlink(TESTFN_UNICODE) |
| 615 | |
| 616 | def testConstructorHandlesNULChars(self): |
| 617 | fn_with_NUL = 'foo\0bar' |