Trees Indices Help
Trac
Package trac :: Package util :: Package tests :: Module concurrency

Source Code for Module trac.util.tests.concurrency

 1 # -*- coding: utf-8 -*- 
 2 # 
 3 # Copyright (C) 2010 Edgewall Software 
 4 # All rights reserved. 
 5 # 
 6 # This software is licensed as described in the file COPYING, which 
 7 # you should have received as part of this distribution. The terms 
 8 # are also available at http://trac.edgewall.org/wiki/TracLicense. 
 9 # 
10 # This software consists of voluntary contributions made by many 
11 # individuals. For the exact contribution history, see the revision 
12 # history and logs, available at http://trac.edgewall.org/log/. 
13 
14 import threading 
15 import unittest 
16 
17 from trac .util .concurrency  import ThreadLocal  
18 
19 
20 - class ThreadLocalTestCase (unittest.TestCase):
21
22 - def test_thread_local (self):
23 local = ThreadLocal (a=1, b =2) 24 local.b = 3 25 local.c = 4 26 local_dict = [local.__dict__.copy()] 27 def f(): 28 local.b = 5 29 local.d = 6 30 local_dict.append(local.__dict__.copy())
31 thread = threading.Thread(target=f) 32 thread.start () 33 thread.join () 34 self.assertEqual (dict(a=1, b =3, c =4), local_dict[0]) 35 self.assertEqual (dict(a=1, b =5, d =6), local_dict[1])
36 37
38 - def suite ():
39 suite = unittest.TestSuite() 40 suite .addTest(unittest.makeSuite(ThreadLocalTestCase , 'test')) 41 return suite
42 43 if __name__ == '__main__': 44 unittest.main (defaultTest='suite') 45
Trees Indices Help
Trac
Generated by Epydoc 3.0.1 on Mon Feb 13 23:37:30 2023 http://epydoc.sourceforge.net

AltStyle によって変換されたページ (->オリジナル) /