From 31fc9917f464d0a2251e108d6c8321c8ac7d7978 Mon Sep 17 00:00:00 2001 From: Martin Sivak Date: Thu, 6 Dec 2012 14:31:00 +0100 Subject: Support accessing (class)attributes of the object decorated by @inject --- di/core_test.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'di/core_test.py') diff --git a/di/core_test.py b/di/core_test.py index 17d88fa..7cbc6bd 100644 --- a/di/core_test.py +++ b/di/core_test.py @@ -1,6 +1,29 @@ +# Tests for the dependency injection core +# +# Copyright (C) 2012 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties 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 this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Martin Sivak +# + from .core import * import unittest +def method_to_inject(): + pass class BareFuncEnableTestCase(unittest.TestCase): @inject(injected_func = str.lower) @@ -70,6 +93,10 @@ class ClassDITestCase(unittest.TestCase): obj = Test() self.assertEqual("a", obj.method("A")) + def test_named_register(self): + """Test injection to instance method.""" + Test.register(method_to_inject) + def test_class_init_inject(self): """Test injection to class constructor.""" obj = TestInit("A") -- cgit