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

Delta Between Two Patch Sets: Lib/test/test_property.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 7 years ago
Right Patch Set: Created 5 years, 10 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_posix.py ('k') | Lib/test/test_pulldom.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 def test_docstring_copy(self): 179 def test_docstring_copy(self):
180 class Foo(object): 180 class Foo(object):
181 @PropertySub 181 @PropertySub
182 def spam(self): 182 def spam(self):
183 """spam wrapped in property subclass""" 183 """spam wrapped in property subclass"""
184 return 1 184 return 1
185 self.assertEqual( 185 self.assertEqual(
186 Foo.spam.__doc__, 186 Foo.spam.__doc__,
187 "spam wrapped in property subclass") 187 "spam wrapped in property subclass")
188 188
189 @unittest.skipIf(sys.flags.optimize <= 2, 189 @unittest.skipIf(sys.flags.optimize >= 2,
190 "Docstrings are omitted with -O2 and above") 190 "Docstrings are omitted with -O2 and above")
191 def test_property_setter_copies_getter_docstring(self): 191 def test_property_setter_copies_getter_docstring(self):
192 class Foo(object): 192 class Foo(object):
193 def __init__(self): self._spam = 1 193 def __init__(self): self._spam = 1
194 @PropertySub 194 @PropertySub
195 def spam(self): 195 def spam(self):
196 """spam wrapped in property subclass""" 196 """spam wrapped in property subclass"""
197 return self._spam 197 return self._spam
198 @spam.setter 198 @spam.setter
199 def spam(self, value): 199 def spam(self, value):
(...skipping 12 matching lines...) Expand all
212 """another ignored docstring""" 212 """another ignored docstring"""
213 self._spam = 'eggs' 213 self._spam = 'eggs'
214 foosub = FooSub() 214 foosub = FooSub()
215 self.assertEqual(foosub.spam, 1) 215 self.assertEqual(foosub.spam, 1)
216 foosub.spam = 7 216 foosub.spam = 7
217 self.assertEqual(foosub.spam, 'eggs') 217 self.assertEqual(foosub.spam, 'eggs')
218 self.assertEqual( 218 self.assertEqual(
219 FooSub.spam.__doc__, 219 FooSub.spam.__doc__,
220 "spam wrapped in property subclass") 220 "spam wrapped in property subclass")
221 221
222 @unittest.skipIf(sys.flags.optimize <= 2, 222 @unittest.skipIf(sys.flags.optimize >= 2,
223 "Docstrings are omitted with -O2 and above") 223 "Docstrings are omitted with -O2 and above")
224 def test_property_new_getter_new_docstring(self): 224 def test_property_new_getter_new_docstring(self):
225 225
226 class Foo(object): 226 class Foo(object):
227 @PropertySub 227 @PropertySub
228 def spam(self): 228 def spam(self):
229 """a docstring""" 229 """a docstring"""
230 return 1 230 return 1
231 @spam.getter 231 @spam.getter
232 def spam(self): 232 def spam(self):
(...skipping 12 matching lines...) Expand all
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()
LEFTRIGHT

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