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

Method test_write_to_fileobj_with_int_name

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

Source from the content-addressed store, hash-verified

1193 unlink(TESTFN)
1194
1195 def test_write_to_fileobj_with_int_name(self):
1196 try:
1197 fd = os.open(TESTFN, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
1198 with open(fd, 'wb') as raw:
1199 with LZMAFile(raw, "w") as f:
1200 f.write(INPUT)
1201 self.assertEqual(f.name, raw.name)
1202 self.assertEqual(f.fileno(), raw.fileno())
1203 self.assertEqual(f.mode, 'wb')
1204 self.assertIs(f.readable(), False)
1205 self.assertIs(f.writable(), True)
1206 self.assertIs(f.seekable(), False)
1207 self.assertIs(f.closed, False)
1208 self.assertIs(f.closed, True)
1209 with self.assertRaises(ValueError):
1210 f.name
1211 self.assertRaises(ValueError, f.fileno)
1212 self.assertEqual(f.mode, 'wb')
1213 self.assertRaises(ValueError, f.readable)
1214 self.assertRaises(ValueError, f.writable)
1215 self.assertRaises(ValueError, f.seekable)
1216
1217 expected = lzma.compress(INPUT)
1218 with open(TESTFN, "rb") as f:
1219 self.assertEqual(f.read(), expected)
1220 finally:
1221 unlink(TESTFN)
1222
1223 def test_write_append_to_file(self):
1224 part1 = INPUT[:1024]

Callers

nothing calls this directly

Calls 14

LZMAFileClass · 0.90
unlinkFunction · 0.90
openFunction · 0.50
openMethod · 0.45
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