FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-100931: Test all `pickle` protocols in `test_slice` by sobolevn · Pull Request #100932 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Lib/test/test_json/test_attrdict.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_pickle(self):
cached_module = sys.modules.get('json')
sys.modules['json'] = self.json
try:
for protocol in range(6):
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This change is not related, but I think it is minor enough to be included. It just replaces a magic number 6 with more context.

kepler_ad2 = pickle.loads(pickle.dumps(kepler_ad, protocol))
self.assertEqual(kepler_ad2, kepler_ad)
self.assertEqual(type(kepler_ad2), AttrDict)
Expand Down
4 changes: 3 additions & 1 deletion Lib/test/test_slice.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ def __setitem__(self, i, k):
self.assertEqual(tmp, [(slice(1, 2), 42)])

def test_pickle(self):
import pickle

s = slice(10, 20, 3)
for protocol in (0,1,2):
for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
t = loads(dumps(s, protocol))
self.assertEqual(s, t)
self.assertEqual(s.indices(15), t.indices(15))
Expand Down

Back | FazBrowse Home | New Git URL