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

Method test_write_to_file

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

Source from the content-addressed store, hash-verified

1138 self.assertEqual(dst.getvalue(), expected)
1139
1140 def test_write_to_file(self):
1141 try:
1142 with LZMAFile(TESTFN, "w") as f:
1143 f.write(INPUT)
1144 self.assertEqual(f.name, TESTFN)
1145 self.assertIsInstance(f.fileno(), int)
1146 self.assertEqual(f.mode, 'wb')
1147 self.assertIs(f.readable(), False)
1148 self.assertIs(f.writable(), True)
1149 self.assertIs(f.seekable(), False)
1150 self.assertIs(f.closed, False)
1151 self.assertIs(f.closed, True)
1152 with self.assertRaises(ValueError):
1153 f.name
1154 self.assertRaises(ValueError, f.fileno)
1155 self.assertEqual(f.mode, 'wb')
1156 self.assertRaises(ValueError, f.readable)
1157 self.assertRaises(ValueError, f.writable)
1158 self.assertRaises(ValueError, f.seekable)
1159
1160 expected = lzma.compress(INPUT)
1161 with open(TESTFN, "rb") as f:
1162 self.assertEqual(f.read(), expected)
1163 finally:
1164 unlink(TESTFN)
1165
1166 def test_write_to_file_with_bytes_filename(self):
1167 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