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

Method test_write_text

Lib/test/test_pathlib/test_write.py:75–82  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 self.assertEqual(self.ground.readbytes(p), data)
74
75 def test_write_text(self):
76 p = self.root / 'fileA'
77 data = 'äbcdefg'
78 self.assertEqual(len(data), p.write_text(data, encoding='latin-1'))
79 self.assertEqual(self.ground.readbytes(p), b'\xe4bcdefg')
80 # Check that trying to write bytes does not truncate the file.
81 self.assertRaises(TypeError, p.write_text, b'somebytes', encoding='utf-8')
82 self.assertEqual(self.ground.readbytes(p), b'\xe4bcdefg')
83
84 @unittest.skipIf(
85 not getattr(sys.flags, 'warn_default_encoding', 0),

Callers

nothing calls this directly

Calls 4

assertEqualMethod · 0.45
write_textMethod · 0.45
readbytesMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected