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

Method test_name

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

Source from the content-addressed store, hash-verified

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