From 35926037a687663729c29edd1942da70929e6f66 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Thu, 5 Sep 2013 21:13:33 +0200 Subject: [PATCH] fix tests --- isso/models.py | 4 ++-- isso/views/comment.py | 3 --- specs/test_comment.py | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/isso/models.py b/isso/models.py index 291ac39..98ba339 100644 --- a/isso/models.py +++ b/isso/models.py @@ -46,7 +46,7 @@ class Comment(object): for field in self.fields: if field == 'text' and field not in data: raise ValueError('Comment needs at least text, but no text was provided.') - comment.__dict__[field] = data.get(field) + setattr(comment, field, data.get(field)) return comment @@ -62,5 +62,5 @@ class Comment(object): def md5(self): hv = hashlib.md5() for key in set(self.fields) - set(['parent', ]): - hv.update(getattr(self, key).encode('utf-8', errors="replace") or u'') + hv.update((getattr(self, key) or u"").encode('utf-8', errors="replace")) return hv.hexdigest() diff --git a/isso/views/comment.py b/isso/views/comment.py index dbccc95..b0f10b1 100644 --- a/isso/views/comment.py +++ b/isso/views/comment.py @@ -45,7 +45,6 @@ def create(app, environ, request, uri): try: comment = models.Comment.fromjson(request.data) except ValueError as e: - print(1) return Response(unicode(e), 400) for attr in 'author', 'email', 'website': @@ -53,13 +52,11 @@ def create(app, environ, request, uri): try: setattr(comment, attr, cgi.escape(getattr(comment, attr))) except AttributeError: - print(1) Response('', 400) try: rv = app.db.add(uri, comment) except ValueError: - print(1) abort(400) # FIXME: custom exception class, error descr md5 = rv.md5 diff --git a/specs/test_comment.py b/specs/test_comment.py index fba92ef..dda07da 100644 --- a/specs/test_comment.py +++ b/specs/test_comment.py @@ -19,7 +19,7 @@ class TestComments(unittest.TestCase): def setUp(self): fd, self.path = tempfile.mkstemp() - self.app = Isso(self.path, '...', '...', 15*60) + self.app = Isso(self.path, '...', '...', 15*60, "...") self.client = Client(self.app, Response) self.get = lambda *x, **z: self.client.get(*x, **z)