From 303f4ed47c10002b4ff797592598036de2e5a778 Mon Sep 17 00:00:00 2001 From: Robert Brownstein Date: Thu, 28 May 2015 17:15:18 -0400 Subject: [PATCH 1/2] Added test coverage for unicode keyword argument support in method signatures (#536) --- tests/fixtures.py | 5 +++++ tests/test_job.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/fixtures.py b/tests/fixtures.py index a2bbefb..09cf02e 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -78,6 +78,11 @@ class CallableObject(object): return u"I'm callable" +class UnicodeStringObject(object): + def __repr__(self): + return u'é'.encode('utf-8') + + with Connection(): @job(queue='default') def decorated_job(x, y): diff --git a/tests/test_job.py b/tests/test_job.py index f6766fe..36570cf 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -399,3 +399,11 @@ class TestJob(RQTestCase): job.perform() self.assertRaises(TypeError, queue.enqueue, fixtures.say_hello, job_id=1234) + + def test_get_call_string_unicode(self): + """test call string with unicode keyword arguments""" + queue = Queue(connection=self.testconn) + + job = queue.enqueue(fixtures.echo, arg_with_unicode=fixtures.UnicodeStringObject()) + self.assertIsNotNone(job.get_call_string()) + job.perform() \ No newline at end of file From 3d8faa0e5d3e7359e71927fee32f9ef3cfd9109d Mon Sep 17 00:00:00 2001 From: Robert Brownstein Date: Thu, 28 May 2015 17:23:04 -0400 Subject: [PATCH 2/2] Added proper conditional behavior to unicode fixture for python 3 --- tests/fixtures.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index 09cf02e..cdb1822 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -11,7 +11,7 @@ import time from rq import Connection, get_current_job from rq.decorators import job - +from rq.compat import PY2 def say_pid(): return os.getpid() @@ -80,7 +80,10 @@ class CallableObject(object): class UnicodeStringObject(object): def __repr__(self): - return u'é'.encode('utf-8') + if PY2: + return u'é'.encode('utf-8') + else: + return u'é' with Connection():