summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--di/__init__.py1
-rw-r--r--di/core.py (renamed from di.py)9
-rw-r--r--python-di.spec41
-rw-r--r--setup.py29
4 files changed, 79 insertions, 1 deletions
diff --git a/di/__init__.py b/di/__init__.py
new file mode 100644
index 0000000..bb67a43
--- /dev/null
+++ b/di/__init__.py
@@ -0,0 +1 @@
+from .core import *
diff --git a/di.py b/di/core.py
index 8ffce38..0962750 100644
--- a/di.py
+++ b/di/core.py
@@ -10,7 +10,8 @@ DI_ENABLE = True
def di_enable(method):
"""This decorator enables DI mechanisms in an environment
- where DI is disabled by default.
+ where DI is disabled by default. Must be the outermost
+ decorator.
Can be used only on methods or simple functions.
"""
@@ -137,6 +138,12 @@ def usesclassinject(method):
### Unittests are defined below this point
import unittest
+
+class BareFuncEnableTestCase(unittest.TestCase):
+ @inject(injected_func = str.lower)
+ def method(self, arg):
+ return injected_func(arg)
+
class BareFuncTestCase(unittest.TestCase):
@inject(injected_func = str.lower)
def method(self, arg):
diff --git a/python-di.spec b/python-di.spec
new file mode 100644
index 0000000..9efd750
--- /dev/null
+++ b/python-di.spec
@@ -0,0 +1,41 @@
+%if 0%{?rhel} && 0%{?rhel} <= 5
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
+%endif
+
+Name: python-di
+Version: 0.1
+Release: 1%{?dist}
+Summary: Python library for dependency injection support
+
+License: GPLv2+
+URL: http://fedorapeople.org/cgit/msivak/public_git/python-di.git/
+Source0: python-di-%{version}-%{release}.tar.gz
+
+#BuildRequires:
+#Requires:
+
+%description
+This python package provides a "di" module. That module contains couple of
+decorators which try to implement Dependency Injection pattern without
+requiring the user to change local variables in his methods.
+
+It is intended to be used in unit testing environments.
+
+%prep
+%setup -q
+
+%build
+%{__python} setup.py make
+
+%install
+%{__python} setup.py install
+
+%files
+%{python_sitelib}/di
+
+%doc
+
+
+
+%changelog
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..2f1a99c
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,29 @@
+import os
+from setuptools import setup
+
+# Utility function to read the README file.
+# Used for the long_description. It's nice, because now 1) we have a top level
+# README file and 2) it's easier to type in the README file than to put a raw
+# string in below ...
+def read(fname):
+ return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+ name = "di",
+ version = "0.1",
+ author = "Martin Sivak",
+ author_email = "msivak@redhat.com",
+ description = ("Python module which provides decorators to make "
+ "dependency injection easy to use."),
+ license = "GPLv2+",
+ keywords = "testing dependency injection IoC",
+ url = "http://fedorapeople.org/cgit/msivak/public_git/python-di.git/",
+ packages = ['di'],
+ long_description=read('README'),
+ classifiers=[
+ "Development Status :: 3 - Alpha",
+ "Intended Audience :: Developers",
+ "Topic :: Software Development :: Testing",
+ "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
+ ],
+)