Package elisa :: Package core :: Package tests :: Module test_singleton
[hide private]
[frames] | no frames]

Source Code for Module elisa.core.tests.test_singleton

 1  # -*- coding: utf-8 -*- 
 2  # Elisa - Home multimedia server 
 3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
 4  # All rights reserved. 
 5  # 
 6  # This file is available under one of two license agreements. 
 7  # 
 8  # This file is licensed under the GPL version 3. 
 9  # See "LICENSE.GPL" in the root of this distribution including a special 
10  # exception to use Elisa with Fluendo's plugins. 
11  # 
12  # The GPL part of Elisa is also available under a commercial licensing 
13  # agreement from Fluendo. 
14  # See "LICENSE.Elisa" in the root directory of this distribution package 
15  # for details on that license. 
16   
17  from twisted.trial import unittest 
18  from elisa.core.tests.elisa_test_case import ElisaTestCase 
19   
20  from elisa.core.utils.singleton import Singleton 
21   
22 -class TestSingleton(ElisaTestCase):
23
24 - def test_same_instance(self):
25 26 class ClassA(Singleton): 27 pass
28 29 class ClassB(ClassA): 30 pass
31 32 # There will be only one instance for ClassA and ClassB 33 34 class ClassC(Singleton): 35 pass 36 37 instance1 = ClassA() 38 instance2 = ClassA() 39 instance3 = ClassB() 40 instance4 = ClassB() 41 42 instance5 = ClassC() 43 instance6 = ClassC() 44 45 self.assertEquals(instance1, instance2) 46 self.assertEquals(instance3, instance4) 47 self.assertEquals(instance5, instance6) 48 49 50 51 if __name__ == "__main__": 52 unittest.main() 53