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

Method testOpenFileWithoutName

Lib/test/test_bz2.py:652–683  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

650 self.assertRaises(ValueError, f.seekable)
651
652 def testOpenFileWithoutName(self):
653 bio = BytesIO()
654 with BZ2File(bio, 'wb') as f:
655 f.write(b'content')
656 with self.assertRaises(AttributeError):
657 f.name
658 self.assertRaises(io.UnsupportedOperation, f.fileno)
659 self.assertEqual(f.mode, 'wb')
660 with self.assertRaises(ValueError):
661 f.name
662 self.assertRaises(ValueError, f.fileno)
663
664 with BZ2File(bio, 'ab') as f:
665 f.write(b'appendix')
666 with self.assertRaises(AttributeError):
667 f.name
668 self.assertRaises(io.UnsupportedOperation, f.fileno)
669 self.assertEqual(f.mode, 'wb')
670 with self.assertRaises(ValueError):
671 f.name
672 self.assertRaises(ValueError, f.fileno)
673
674 bio.seek(0)
675 with BZ2File(bio, 'rb') as f:
676 self.assertEqual(f.read(), b'contentappendix')
677 with self.assertRaises(AttributeError):
678 f.name
679 self.assertRaises(io.UnsupportedOperation, f.fileno)
680 self.assertEqual(f.mode, 'rb')
681 with self.assertRaises(ValueError):
682 f.name
683 self.assertRaises(ValueError, f.fileno)
684
685 def testOpenFileWithIntName(self):
686 fd = os.open(self.filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)

Callers

nothing calls this directly

Calls 7

seekMethod · 0.95
BytesIOClass · 0.90
BZ2FileClass · 0.90
writeMethod · 0.45
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected