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

Method test_write_to_file

Lib/test/test_lzma.py:1130–1154  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1128 self.assertEqual(dst.getvalue(), expected)
1129
1130 def test_write_to_file(self):
1131 try:
1132 with LZMAFile(TESTFN, "w") as f:
1133 f.write(INPUT)
1134 self.assertEqual(f.name, TESTFN)
1135 self.assertIsInstance(f.fileno(), int)
1136 self.assertEqual(f.mode, 'wb')
1137 self.assertIs(f.readable(), False)
1138 self.assertIs(f.writable(), True)
1139 self.assertIs(f.seekable(), False)
1140 self.assertIs(f.closed, False)
1141 self.assertIs(f.closed, True)
1142 with self.assertRaises(ValueError):
1143 f.name
1144 self.assertRaises(ValueError, f.fileno)
1145 self.assertEqual(f.mode, 'wb')
1146 self.assertRaises(ValueError, f.readable)
1147 self.assertRaises(ValueError, f.writable)
1148 self.assertRaises(ValueError, f.seekable)
1149
1150 expected = lzma.compress(INPUT)
1151 with open(TESTFN, "rb") as f:
1152 self.assertEqual(f.read(), expected)
1153 finally:
1154 unlink(TESTFN)
1155
1156 def test_write_to_file_with_bytes_filename(self):
1157 bytes_filename = os.fsencode(TESTFN)

Callers

nothing calls this directly

Calls 14

LZMAFileClass · 0.90
unlinkFunction · 0.90
assertIsInstanceMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
assertEqualMethod · 0.45
filenoMethod · 0.45
assertIsMethod · 0.45
readableMethod · 0.45
writableMethod · 0.45
seekableMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected