diff --git a/rq/compat/__init__.py b/rq/compat/__init__.py index 5e660b5..3095983 100644 --- a/rq/compat/__init__.py +++ b/rq/compat/__init__.py @@ -69,7 +69,9 @@ else: string_types = (str, unicode) def as_text(v): - return v + if v is None: + return None + return v.decode('utf-8') def decode_redis_hash(h): return h diff --git a/tests/test_worker.py b/tests/test_worker.py index 764cf46..c6d85ff 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -307,3 +307,14 @@ class TestWorker(RQTestCase): # Updates worker statuses self.assertEqual(worker.state, 'busy') self.assertEqual(worker.get_current_job_id(), job.id) + + def test_work_unicode_friendly(self): + """Worker processes work with unicode description, then quits.""" + q = Queue('foo') + w = Worker([q]) + job = q.enqueue('tests.fixtures.say_hello', name='Adam', + description='你好 世界!') + self.assertEquals(w.work(burst=True), True, + 'Expected at least some work done.') + self.assertEquals(job.result, 'Hi there, Adam!') + self.assertEquals(job.description, '你好 世界!')