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

Method testOpenFileWithoutName

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

Source from the content-addressed store, hash-verified

660 self.assertRaises(ValueError, f.seekable)
661
662 def testOpenFileWithoutName(self):
663 bio = BytesIO()
664 with BZ2File(bio, 'wb') as f:
665 f.write(b'content')
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 with BZ2File(bio, 'ab') as f:
675 f.write(b'appendix')
676 with self.assertRaises(AttributeError):
677 f.name
678 self.assertRaises(io.UnsupportedOperation, f.fileno)
679 self.assertEqual(f.mode, 'wb')
680 with self.assertRaises(ValueError):
681 f.name
682 self.assertRaises(ValueError, f.fileno)
683
684 bio.seek(0)
685 with BZ2File(bio, 'rb') as f:
686 self.assertEqual(f.read(), b'contentappendix')
687 with self.assertRaises(AttributeError):
688 f.name
689 self.assertRaises(io.UnsupportedOperation, f.fileno)
690 self.assertEqual(f.mode, 'rb')
691 with self.assertRaises(ValueError):
692 f.name
693 self.assertRaises(ValueError, f.fileno)
694
695 def testOpenFileWithIntName(self):
696 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