Skip to content

Commit d52f5dd

Browse files
Use subtests for test_stat_result_pickle.
1 parent 62179ba commit d52f5dd

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Lib/test/test_os.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,13 @@ def test_stat_attributes_bytes(self):
606606
def test_stat_result_pickle(self):
607607
result = os.stat(self.fname)
608608
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
609-
p = pickle.dumps(result, proto)
610-
self.assertIn(b'stat_result', p)
611-
if proto < 4:
612-
self.assertIn(b'cos\nstat_result\n', p)
613-
unpickled = pickle.loads(p)
614-
self.assertEqual(result, unpickled)
609+
with self.subTest(f'protocol {proto}'):
610+
p = pickle.dumps(result, proto)
611+
self.assertIn(b'stat_result', p)
612+
if proto < 4:
613+
self.assertIn(b'cos\nstat_result\n', p)
614+
unpickled = pickle.loads(p)
615+
self.assertEqual(result, unpickled)
615616

616617
@unittest.skipUnless(hasattr(os, 'statvfs'), 'test needs os.statvfs()')
617618
def test_statvfs_attributes(self):

0 commit comments

Comments
 (0)