GitModifier: Don't use self.__dict__.update(locals())
authorGuido Günther <g.guenther@tarent.de>
Fri, 28 Oct 2011 08:14:34 +0000 (10:14 +0200)
committerGuido Günther <agx@sigxcpu.org>
Fri, 28 Oct 2011 16:48:19 +0000 (18:48 +0200)
to make pychecker happy

debian/rules
gbp/git.py
tests/test_GitModifier.py [new file with mode: 0644]

index a2bc921..d70542f 100755 (executable)
@@ -54,7 +54,7 @@ links_stamp:
        
 apidocs: links_stamp
        epydoc -v -n git-buildpackage --no-sourcecode -o docs/apidocs/ \
-               gbp*.py git*.py gbp/ tests/test_GitRepository.py
+               gbp*.py git*.py gbp/ tests/test_Git*.py
 
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
 pychecker:
index 48e9366..d4192f0 100644 (file)
@@ -33,7 +33,9 @@ class GitRepositoryError(Exception):
 class GitModifier(object):
     """Stores authorship/comitter information"""
     def __init__(self, name=None, email=None, date=None):
-        self.__dict__.update(locals())
+        self.name = name
+        self.email = email
+        self.date = date
 
     def _get_env(self, who):
         """Get author or comitter information as env var dictionary"""
diff --git a/tests/test_GitModifier.py b/tests/test_GitModifier.py
new file mode 100644 (file)
index 0000000..10188a0
--- /dev/null
@@ -0,0 +1,23 @@
+# vim: set fileencoding=utf-8 :
+
+"""
+Test L{gbp.git.GitModifier}
+"""
+
+def test_author():
+    """
+    Methods tested:
+         - L{gbp.git.GitModifer.get_author_env}
+         - L{gbp.git.GitModifer.get_comitter_env}
+
+    >>> import gbp.git
+    >>> modifier = gbp.git.GitModifier("foo", "bar")
+    >>> modifier.name
+    'foo'
+    >>> modifier.email
+    'bar'
+    >>> modifier.get_author_env()
+    {'GIT_AUTHOR_EMAIL': 'bar', 'GIT_AUTHOR_NAME': 'foo'}
+    >>> modifier.get_committer_env()
+    {'GIT_COMMITTER_NAME': 'foo', 'GIT_COMMITTER_EMAIL': 'bar'}
+    """