Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73e5e65

Browse files
committed
Add more tests for PyStructSequence with invisible fields
1 parent 83fd01b commit 73e5e65

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Lib/test/test_structseq.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,16 @@ def test_copy_replace_has_invisible_fields(self):
170170
(2000, 2, 1, 0, 0, 0, 3, 1, 0))
171171

172172
# named invisible fields
173+
self.assertHasAttr(t, 'tm_zone')
173174
with self.assertRaisesRegex(AttributeError, 'readonly attribute'):
174175
t.tm_zone = 'some other zone'
175-
self.assertHasAttr(t, 'tm_zone')
176-
self.assertEqual(copy.replace(t, tm_zone='some other zone').tm_zone,
177-
'some other zone')
176+
t2 = copy.replace(t, tm_zone='some other zone')
177+
self.assertEqual(t, t2)
178+
self.assertEqual(t2.tm_zone, 'some other zone')
179+
t3 = copy.replace(t, tm_year=2000, tm_zone='some other zone')
180+
self.assertEqual(t3, (2000, 1, 1, 0, 0, 0, 3, 1, 0))
181+
self.assertEqual(t3.tm_year, 2000)
182+
self.assertEqual(t3.tm_zone, 'some other zone')
178183

179184
# unknown fields
180185
with self.assertRaisesRegex(ValueError, 'unexpected field name'):

0 commit comments

Comments
 (0)