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

Method test_from_file

Lib/test/test_zoneinfo/test_zoneinfo.py:1729–1746  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1727 self.assertIsNot(zi_rt, zi_cache)
1728
1729 def test_from_file(self):
1730 key = "Europe/Dublin"
1731 with open(self.zoneinfo_data.path_from_key(key), "rb") as f:
1732 zi_nokey = self.klass.from_file(f)
1733
1734 f.seek(0)
1735 zi_key = self.klass.from_file(f, key=key)
1736
1737 test_cases = [
1738 (zi_key, "ZoneInfo with key"),
1739 (zi_nokey, "ZoneInfo without key"),
1740 ]
1741
1742 for zi, test_name in test_cases:
1743 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
1744 with self.subTest(test_name=test_name, proto=proto):
1745 with self.assertRaises(pickle.PicklingError):
1746 pickle.dumps(zi, protocol=proto)
1747
1748 def test_pickle_after_from_file(self):
1749 # This may be a bit of paranoia, but this test is to ensure that no

Callers

nothing calls this directly

Calls 7

path_from_keyMethod · 0.80
openFunction · 0.50
from_fileMethod · 0.45
seekMethod · 0.45
subTestMethod · 0.45
assertRaisesMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected