Skip to content
7 changes: 2 additions & 5 deletions Lib/test/test_funcattrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,16 @@ def f(): return a
c[0].cell_contents = 9
self.assertEqual(c[0].cell_contents, 9)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It would be nice to check how setting and deleting cell_contents affects the local variable a.

self.assertEqual(f(), 9)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also check a directly.

self.assertEqual(a, 9)

self.assertEqual(a, 9)
del c[0].cell_contents
try:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I understand that you have copied an example from the above test, but this is too verbose. with self.assertRaises(ValueError): is much more compact.

c[0].cell_contents
except ValueError:
pass
else:
self.fail("shouldn't be able to read an empty cell")
try:
with self.assertRaises(NameError):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also check a directly.

f()
except NameError:
pass
else:
self.fail("variable not deleted")

def test___name__(self):
self.assertEqual(self.b.__name__, 'b')
Expand Down