MCPcopy Index your code
hub / github.com/python/cpython / testUtf8BytesOpen

Method testUtf8BytesOpen

Lib/test/test_io/test_fileio.py:601–614  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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'

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