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

Method test_init_bad_mode

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

Source from the content-addressed store, hash-verified

1635 os.remove(filename)
1636
1637 def test_init_bad_mode(self):
1638 with self.assertRaises(ValueError):
1639 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), (3, "x"))
1640 with self.assertRaises(ValueError):
1641 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "")
1642 with self.assertRaises(ValueError):
1643 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "xt")
1644 with self.assertRaises(ValueError):
1645 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "x+")
1646 with self.assertRaises(ValueError):
1647 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "rx")
1648 with self.assertRaises(ValueError):
1649 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "wx")
1650 with self.assertRaises(ValueError):
1651 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "rt")
1652 with self.assertRaises(ValueError):
1653 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "r+")
1654 with self.assertRaises(ValueError):
1655 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "wt")
1656 with self.assertRaises(ValueError):
1657 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "w+")
1658 with self.assertRaises(ValueError):
1659 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "rw")
1660
1661 with self.assertRaisesRegex(TypeError,
1662 r"not be a CompressionParameter"):
1663 ZstdFile(io.BytesIO(), 'rb',
1664 options={CompressionParameter.compression_level:5})
1665 with self.assertRaisesRegex(TypeError,
1666 r"not be a DecompressionParameter"):
1667 ZstdFile(io.BytesIO(), 'wb',
1668 options={DecompressionParameter.window_log_max:21})
1669
1670 with self.assertRaises(TypeError):
1671 ZstdFile(io.BytesIO(COMPRESSED_100_PLUS_32KB), "r", level=12)
1672
1673 def test_init_bad_check(self):
1674 with self.assertRaises(TypeError):

Callers

nothing calls this directly

Calls 3

ZstdFileClass · 0.90
assertRaisesRegexMethod · 0.80
assertRaisesMethod · 0.45

Tested by

no test coverage detected