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

Method test_fileno

Lib/test/test_zstd.py:1754–1783  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1752 self.assertTrue(f.closed)
1753
1754 def test_fileno(self):
1755 # 1
1756 f = ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB))
1757 try:
1758 self.assertRaises(io.UnsupportedOperation, f.fileno)
1759 finally:
1760 f.close()
1761 self.assertRaises(ValueError, f.fileno)
1762
1763 # 2
1764 with tempfile.NamedTemporaryFile(delete=False) as tmp_f:
1765 filename = pathlib.Path(tmp_f.name)
1766
1767 f = ZstdFile(filename)
1768 try:
1769 self.assertEqual(f.fileno(), f._fp.fileno())
1770 self.assertIsInstance(f.fileno(), int)
1771 finally:
1772 f.close()
1773 self.assertRaises(ValueError, f.fileno)
1774
1775 os.remove(filename)
1776
1777 # 3, no .fileno() method
1778 class C:
1779 def read(self, size=-1):
1780 return b'123'
1781 with ZstdFile(C(), 'rb') as f:
1782 with self.assertRaisesRegex(AttributeError, r'fileno'):
1783 f.fileno()
1784
1785 def test_name(self):
1786 # 1

Callers

nothing calls this directly

Calls 10

closeMethod · 0.95
filenoMethod · 0.95
ZstdFileClass · 0.90
assertIsInstanceMethod · 0.80
assertRaisesRegexMethod · 0.80
CClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45
filenoMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected