MCPcopy Index your code
hub / github.com/RustPython/RustPython / testUtf8BytesOpen

Method testUtf8BytesOpen

Lib/test/test_fileio.py:602–615  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 8

writeMethod · 0.95
closeMethod · 0.95
readMethod · 0.95
skipTestMethod · 0.80
encodeMethod · 0.45
openMethod · 0.45
assertEqualMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected