From ae15779c8137420f9cd66b471e883badc56c6349 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 7 Oct 2011 17:50:53 +0200 Subject: [PATCH 1/2] -- DeprecationWarning: object.__new__() takes no parameters Signed-off-by: Steven Armstrong --- lib/cdist/core/type.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cdist/core/type.py b/lib/cdist/core/type.py index 42a74398..a9a34946 100644 --- a/lib/cdist/core/type.py +++ b/lib/cdist/core/type.py @@ -52,7 +52,7 @@ class Type(object): # name is second argument name = args[1] if not name in cls._instances: - instance = super(Type, cls).__new__(cls, *args, **kwargs) + instance = super(Type, cls).__new__(cls) cls._instances[name] = instance return cls._instances[name] From f515e20572c314fa99012e675b05338e8d3283ab Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 7 Oct 2011 17:52:38 +0200 Subject: [PATCH 2/2] start unittests for Type Signed-off-by: Steven Armstrong --- lib/cdist/test/type/__init__.py | 0 .../test/type/fixtures/__not_singleton/.keep | 0 .../test/type/fixtures/__singleton/singleton | 0 lib/cdist/test/type/test_type.py | 61 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 lib/cdist/test/type/__init__.py create mode 100644 lib/cdist/test/type/fixtures/__not_singleton/.keep create mode 100644 lib/cdist/test/type/fixtures/__singleton/singleton create mode 100644 lib/cdist/test/type/test_type.py diff --git a/lib/cdist/test/type/__init__.py b/lib/cdist/test/type/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/cdist/test/type/fixtures/__not_singleton/.keep b/lib/cdist/test/type/fixtures/__not_singleton/.keep new file mode 100644 index 00000000..e69de29b diff --git a/lib/cdist/test/type/fixtures/__singleton/singleton b/lib/cdist/test/type/fixtures/__singleton/singleton new file mode 100644 index 00000000..e69de29b diff --git a/lib/cdist/test/type/test_type.py b/lib/cdist/test/type/test_type.py new file mode 100644 index 00000000..de202b8b --- /dev/null +++ b/lib/cdist/test/type/test_type.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# +# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +import os +import tempfile +import unittest +import shutil + +import cdist.core + +import os.path as op +my_dir = op.abspath(op.dirname(__file__)) +fixtures = op.join(my_dir, 'fixtures') + + +class TypeTestCase(unittest.TestCase): + def setUp(self): + # FIXME: use defined set of types for testing? + # FIXME: generate object tree or use predefined? + self.temp_dir = tempfile.mkdtemp() + self.object_base_path = op.join(self.temp_dir, '') + + def tearDown(self): + shutil.rmtree(self.temp_dir) + + def test_singleton_is_singleton(self): + base_path = fixtures + cdist_type = cdist.core.Type(base_path, '__singleton') + self.assertTrue(cdist_type.is_singleton) + + def test_not_singleton_is_singleton(self): + base_path = fixtures + cdist_type = cdist.core.Type(base_path, '__not_singleton') + self.assertFalse(cdist_type.is_singleton) + + +''' +suite = unittest.TestLoader().loadTestsFromTestCase(ObjectTestCase) + +def suite(): + tests = [] + return unittest.TestSuite(map(ObjectTestCase, tests)) +'''