def test_forgetAllSingletons(self):
        # Should work if there are no singletons
        forgetAllSingletons()

        class A(Singleton):
            ciInitCount = 0

            def __init__(self):
                super(A, self).__init__()
                A.ciInitCount += 1

        A.getInstance()
        self.assertEqual(A.ciInitCount, 1)

        A.getInstance()
        self.assertEqual(A.ciInitCount, 1)

        forgetAllSingletons()
        A.getInstance()
        self.assertEqual(A.ciInitCount, 2)
Пример #2
0
 def tearDown(self):
     singleton.forgetAllSingletons()