From ad66d872f0a51579ccdf245ef73358e7678a43f2 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Fri, 26 Oct 2018 20:27:36 +0700 Subject: [PATCH] Fixed a unicode test. --- tests/fixtures.py | 4 ++-- tests/test_worker.py | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index b497b6c..16c2134 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -12,7 +12,7 @@ import sys from rq import Connection, get_current_job, get_current_connection, Queue from rq.decorators import job -from rq.compat import PY2 +from rq.compat import PY2, text_type from rq.worker import HerokuWorker @@ -29,7 +29,7 @@ def say_hello(name=None): def say_hello_unicode(name=None): """A job with a single argument and a return value.""" - return unicode(say_hello(name)) # noqa + return text_type(say_hello(name)) # noqa def do_nothing(): diff --git a/tests/test_worker.py b/tests/test_worker.py index 868ef8d..2f0a9df 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -579,14 +579,16 @@ class TestWorker(RQTestCase): logging work properly""" q = Queue("foo") w = Worker([q]) - q.enqueue('tests.fixtures.say_hello', name='阿达姆', - description='你好 世界!') - self.assertEqual(w.work(burst=True), True, - 'Expected at least some work done.') - q.enqueue('tests.fixtures.say_hello_unicode', name='阿达姆', - description='你好 世界!') - self.assertEqual(w.work(burst=True), True, - 'Expected at least some work done.') + + job = q.enqueue('tests.fixtures.say_hello', name='阿达姆', + description='你好 世界!') + w.work(burst=True) + self.assertEqual(job.get_status(), JobStatus.FINISHED) + + job = q.enqueue('tests.fixtures.say_hello_unicode', name='阿达姆', + description='你好 世界!') + w.work(burst=True) + self.assertEqual(job.get_status(), JobStatus.FINISHED) def test_suspend_worker_execution(self): """Test Pause Worker Execution"""