diff --git a/rq/job.py b/rq/job.py index e8080f8..a2cf6a2 100644 --- a/rq/job.py +++ b/rq/job.py @@ -407,7 +407,8 @@ class Job(object): self.created_at = to_date(as_text(obj.get('created_at'))) self.origin = as_text(obj.get('origin')) - self.description = as_text(obj.get('description')) + self.description = (as_text(obj.get('description')).decode('unicode_escape') + if obj.get('description') else None) self.enqueued_at = to_date(as_text(obj.get('enqueued_at'))) self.ended_at = to_date(as_text(obj.get('ended_at'))) self._result = unpickle(obj.get('result')) if obj.get('result') else None # noqa 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, '你好 世界!')