예제 #1
0
    def test_singletons_can_be_reset(self):
        instance_a = Singleton.singleton()
        Singleton.reset_singleton()
        instance_b = Singleton.singleton()

        self.assertTrue(instance_a is not instance_b,
                        'Singleton.singleton() should return a different instance after reset.')
예제 #2
0
    def test_singletons_can_be_reset(self):
        instance_a = Singleton.singleton()
        Singleton.reset_singleton()
        instance_b = Singleton.singleton()

        self.assertTrue(
            instance_a is not instance_b,
            'Singleton.singleton() should return a different instance after reset.'
        )
예제 #3
0
    def test_singleton_raises_error_on_multiple_instantiations(self):
        instance_a = Singleton.singleton()

        with self.assertRaises(
                SingletonError,
                msg='Instantiating more than once should raise an error.'):
            instance_b = Singleton()
예제 #4
0
 def test_singleton_returns_same_instance_every_time(self):
     instance_a = Singleton.singleton()
     instance_b = Singleton.singleton()
     self.assertIs(
         instance_a, instance_b,
         'Singleton.singleton() should return the same instance.')
예제 #5
0
 def test_singleton_returns_same_instance_every_time(self):
     instance_a = Singleton.singleton()
     instance_b = Singleton.singleton()
     self.assertIs(instance_a, instance_b, 'Singleton.singleton() should return the same instance.')
예제 #6
0
    def test_singleton_raises_error_on_multiple_instantiations(self):
        instance_a = Singleton.singleton()

        with self.assertRaises(SingletonError, msg='Instantiating more than once should raise an error.'):
            instance_b = Singleton()