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

Method test_write_text

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

lenFunction · 0.85
assertEqualMethod · 0.45
write_textMethod · 0.45
readbytesMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected