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

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

Issue 3232042: #9424: convert deprecated assert methods in the Python test suite Base URL: http://svn.python.org/projects/python/branches/py3k/
Patch Set: Minor cleanups Created 14 years, 2 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_deque.py ('k') | Lib/test/test_epoll.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 import builtins 1 import builtins
2 import sys 2 import sys
3 import types 3 import types
4 import math 4 import math
5 import unittest 5 import unittest
6 6
7 from copy import deepcopy 7 from copy import deepcopy
8 from test import support 8 from test import support
9 9
10 10
(...skipping 4187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4198 descr = Descriptor() 4198 descr = Descriptor()
4199 class A(object): 4199 class A(object):
4200 __getattribute__ = descr 4200 __getattribute__ = descr
4201 class B(object): 4201 class B(object):
4202 __getattr__ = descr 4202 __getattr__ = descr
4203 class C(object): 4203 class C(object):
4204 __getattribute__ = descr 4204 __getattribute__ = descr
4205 __getattr__ = descr 4205 __getattr__ = descr
4206 4206
4207 self.assertRaises(AttributeError, getattr, A(), "attr") 4207 self.assertRaises(AttributeError, getattr, A(), "attr")
4208 self.assertEquals(descr.counter, 1) 4208 self.assertEqual(descr.counter, 1)
4209 self.assertRaises(AttributeError, getattr, B(), "attr") 4209 self.assertRaises(AttributeError, getattr, B(), "attr")
4210 self.assertEquals(descr.counter, 2) 4210 self.assertEqual(descr.counter, 2)
4211 self.assertRaises(AttributeError, getattr, C(), "attr") 4211 self.assertRaises(AttributeError, getattr, C(), "attr")
4212 self.assertEquals(descr.counter, 4) 4212 self.assertEqual(descr.counter, 4)
4213 4213
4214 import gc 4214 import gc
4215 class EvilGetattribute(object): 4215 class EvilGetattribute(object):
4216 # This used to segfault 4216 # This used to segfault
4217 def __getattr__(self, name): 4217 def __getattr__(self, name):
4218 raise AttributeError(name) 4218 raise AttributeError(name)
4219 def __getattribute__(self, name): 4219 def __getattribute__(self, name):
4220 del EvilGetattribute.__getattr__ 4220 del EvilGetattribute.__getattr__
4221 for i in range(5): 4221 for i in range(5):
4222 gc.collect() 4222 gc.collect()
4223 raise AttributeError(name) 4223 raise AttributeError(name)
4224 4224
4225 self.assertRaises(AttributeError, getattr, EvilGetattribute(), "attr") 4225 self.assertRaises(AttributeError, getattr, EvilGetattribute(), "attr")
4226 4226
4227 4227
4228 class DictProxyTests(unittest.TestCase): 4228 class DictProxyTests(unittest.TestCase):
4229 def setUp(self): 4229 def setUp(self):
4230 class C(object): 4230 class C(object):
4231 def meth(self): 4231 def meth(self):
4232 pass 4232 pass
4233 self.C = C 4233 self.C = C
4234 4234
4235 def test_iter_keys(self): 4235 def test_iter_keys(self):
4236 # Testing dict-proxy iterkeys... 4236 # Testing dict-proxy iterkeys...
4237 keys = [ key for key in self.C.__dict__.keys() ] 4237 keys = [ key for key in self.C.__dict__.keys() ]
4238 keys.sort() 4238 keys.sort()
4239 self.assertEquals(keys, ['__dict__', '__doc__', '__module__', 4239 self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
4240 '__weakref__', 'meth']) 4240 '__weakref__', 'meth'])
4241 4241
4242 def test_iter_values(self): 4242 def test_iter_values(self):
4243 # Testing dict-proxy itervalues... 4243 # Testing dict-proxy itervalues...
4244 values = [ values for values in self.C.__dict__.values() ] 4244 values = [ values for values in self.C.__dict__.values() ]
4245 self.assertEqual(len(values), 5) 4245 self.assertEqual(len(values), 5)
4246 4246
4247 def test_iter_items(self): 4247 def test_iter_items(self):
4248 # Testing dict-proxy iteritems... 4248 # Testing dict-proxy iteritems...
4249 keys = [ key for (key, value) in self.C.__dict__.items() ] 4249 keys = [ key for (key, value) in self.C.__dict__.items() ]
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 type.mro(tuple) 4285 type.mro(tuple)
4286 4286
4287 4287
4288 def test_main(): 4288 def test_main():
4289 # Run all local test cases, with PTypesLongInitTest first. 4289 # Run all local test cases, with PTypesLongInitTest first.
4290 support.run_unittest(PTypesLongInitTest, OperatorsTest, 4290 support.run_unittest(PTypesLongInitTest, OperatorsTest,
4291 ClassPropertiesAndMethods, DictProxyTests) 4291 ClassPropertiesAndMethods, DictProxyTests)
4292 4292
4293 if __name__ == "__main__": 4293 if __name__ == "__main__":
4294 test_main() 4294 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_deque.py ('k') | Lib/test/test_epoll.py » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b