Package logilab :: Package common :: Package test :: Module unittest_deprecation
[frames] | no frames]

Source Code for Module logilab.common.test.unittest_deprecation

 1  """unit tests for logilab.common.deprecation""" 
 2   
 3  import warnings 
 4   
 5  from logilab.common.testlib import TestCase, unittest_main 
 6  from logilab.common import deprecation 
7 8 -def moving_target():
9 pass
10
11 -class RawInputTC(TestCase):
12 13 # XXX with 2.6 we could test warnings 14 # http://docs.python.org/library/warnings.html#testing-warnings 15 # instead we just make sure it does not crash
16 - def setUp(self):
17 warnings.simplefilter("ignore")
18 - def tearDown(self):
19 warnings.simplefilter("default")
20
21 - def mk_func(self):
22 def any_func(): 23 pass
24 return any_func
25
26 - def test_class_deprecated(self):
27 class AnyClass: 28 __metaclass__ = deprecation.class_deprecated
29
30 - def test_deprecated_func(self):
31 any_func = deprecation.deprecated()(self.mk_func()) 32 any_func() 33 any_func = deprecation.deprecated('message')(self.mk_func()) 34 any_func()
35
36 - def test_deprecated_decorator(self):
37 @deprecation.deprecated_function 38 def any_func(): 39 pass
40 any_func() 41 42 @deprecation.deprecated() 43 def any_func(): 44 pass 45 any_func() 46 47 @deprecation.deprecated('message') 48 def any_func(): 49 pass 50 any_func() 51
52 - def test_moved(self):
53 # this test needs l.c.test.__init__ 54 module = 'logilab.common.test.unittest_deprecation' 55 any_func = deprecation.moved(module, 'moving_target') 56 any_func()
57 58 if __name__ == '__main__': 59 unittest_main() 60