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

Method test_name

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

Source from the content-addressed store, hash-verified

1783 f.fileno()
1784
1785 def test_name(self):
1786 # 1
1787 f = ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB))
1788 try:
1789 with self.assertRaises(AttributeError):
1790 f.name
1791 finally:
1792 f.close()
1793 with self.assertRaises(ValueError):
1794 f.name
1795
1796 # 2
1797 with tempfile.NamedTemporaryFile(delete=False) as tmp_f:
1798 filename = pathlib.Path(tmp_f.name)
1799
1800 f = ZstdFile(filename)
1801 try:
1802 self.assertEqual(f.name, f._fp.name)
1803 self.assertIsInstance(f.name, str)
1804 finally:
1805 f.close()
1806 with self.assertRaises(ValueError):
1807 f.name
1808
1809 os.remove(filename)
1810
1811 # 3, no .filename property
1812 class C:
1813 def read(self, size=-1):
1814 return b'123'
1815 with ZstdFile(C(), 'rb') as f:
1816 with self.assertRaisesRegex(AttributeError, r'name'):
1817 f.name
1818
1819 def test_seekable(self):
1820 f = ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB))

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected