# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4

# Copyright (c) 2010-2011, GEM Foundation.
#
# OpenQuake is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# only, as published by the Free Software Foundation.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License version 3 for more details
# (a copy is included in the LICENSE file that accompanied this code).
#
# You should have received a copy of the GNU Lesser General Public License
# version 3 along with OpenQuake.  If not, see
# <http://www.gnu.org/licenses/lgpl-3.0.txt> for a copy of the LGPLv3 License.


"""
Test related to code in openquake/utils/general.py
"""


@@ -894,8 +894,604 @@
 py%0A%22%22%22%0A%0A
+%0Aimport unittest%0A%0Afrom openquake.utils import general%0A%0A%0Aclass SingletonTestCase(unittest.TestCase):%0A    %22%22%22Tests the behaviour of utils.general.singleton().%22%22%22%0A%0A    def test_singleton(self):%0A        %22%22%22%0A        A class decorated with @singleton will always return the same%0A        instance upon creation.%0A        %22%22%22%0A%0A        @general.singleton%0A        class MySingleton(object):%0A            pass%0A%0A        instance1 = MySingleton()%0A        instance2 = MySingleton()%0A        self.assertTrue(instance2 is instance1)%0A        instance3 = MySingleton()%0A        self.assertTrue(instance3 is instance1)%0A

add unit tests for the @singleton decorator