Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(83174)

Side by Side Diff: Lib/test/test_property.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_posix.py ('k') | Lib/test/test_pulldom.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Test case for property 1 # Test case for property
2 # more tests are in test_descr 2 # more tests are in test_descr
3 3
4 import sys 4 import sys
5 import unittest 5 import unittest
6 from test.support import run_unittest 6 from test.support import run_unittest
7 7
8 class PropertyBase(Exception): 8 class PropertyBase(Exception):
9 pass 9 pass
10 10
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 class PropertyTests(unittest.TestCase): 80 class PropertyTests(unittest.TestCase):
81 def test_property_decorator_baseclass(self): 81 def test_property_decorator_baseclass(self):
82 # see #1620 82 # see #1620
83 base = BaseClass() 83 base = BaseClass()
84 self.assertEqual(base.spam, 5) 84 self.assertEqual(base.spam, 5)
85 self.assertEqual(base._spam, 5) 85 self.assertEqual(base._spam, 5)
86 base.spam = 10 86 base.spam = 10
87 self.assertEqual(base.spam, 10) 87 self.assertEqual(base.spam, 10)
88 self.assertEqual(base._spam, 10) 88 self.assertEqual(base._spam, 10)
89 delattr(base, "spam") 89 delattr(base, "spam")
90 self.assertTrue(not hasattr(base, "spam")) 90 self.assertFalse(hasattr(base, "spam"))
91 self.assertTrue(not hasattr(base, "_spam")) 91 self.assertFalse(hasattr(base, "_spam"))
92 base.spam = 20 92 base.spam = 20
93 self.assertEqual(base.spam, 20) 93 self.assertEqual(base.spam, 20)
94 self.assertEqual(base._spam, 20) 94 self.assertEqual(base._spam, 20)
95 95
96 def test_property_decorator_subclass(self): 96 def test_property_decorator_subclass(self):
97 # see #1620 97 # see #1620
98 sub = SubClass() 98 sub = SubClass()
99 self.assertRaises(PropertyGet, getattr, sub, "spam") 99 self.assertRaises(PropertyGet, getattr, sub, "spam")
100 self.assertRaises(PropertySet, setattr, sub, "spam", None) 100 self.assertRaises(PropertySet, setattr, sub, "spam", None)
101 self.assertRaises(PropertyDel, delattr, sub, "spam") 101 self.assertRaises(PropertyDel, delattr, sub, "spam")
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return 2 245 return 2
246 self.assertEqual(Foo.spam.__doc__, "a new docstring") 246 self.assertEqual(Foo.spam.__doc__, "a new docstring")
247 247
248 248
249 249
250 def test_main(): 250 def test_main():
251 run_unittest(PropertyTests, PropertySubclassTests) 251 run_unittest(PropertyTests, PropertySubclassTests)
252 252
253 if __name__ == '__main__': 253 if __name__ == '__main__':
254 test_main() 254 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_posix.py ('k') | Lib/test/test_pulldom.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+