Merge pull request #492 from dwaynebailey/master

Allow non-ASCII characters in arguments
main
Selwin Ong 10 years ago
commit 5bcca82ea4

@ -514,8 +514,15 @@ class Job(object):
if self.func_name is None: if self.func_name is None:
return None return None
# Python 2/3 compatibility
try:
arg_list = [repr(arg).decode('utf-8') for arg in self.args]
except AttributeError:
arg_list = [repr(arg) for arg in self.args] arg_list = [repr(arg) for arg in self.args]
arg_list += ['%s=%r' % (k, v) for k, v in self.kwargs.items()]
kwargs = ['{0}={1!r}'.format(k, v) for k, v in self.kwargs.items()]
# Sort here because python 3.3 & 3.4 makes different call_string
arg_list += sorted(kwargs)
args = ', '.join(arg_list) args = ', '.join(arg_list)
return '%s(%s)' % (self.func_name, args) return '%s(%s)' % (self.func_name, args)

@ -23,6 +23,26 @@ except ImportError:
class TestJob(RQTestCase): class TestJob(RQTestCase):
def test_unicode(self):
"""Unicode in job description [issue405]"""
job = Job.create(
'myfunc',
args=[12, ""],
kwargs=dict(snowman="", null=None),
)
try:
# Python 2
test_string = u"myfunc(12, u'\\u2603', null=None, snowman=u'\\u2603')".decode('utf-8')
except AttributeError:
# Python 3
test_string = "myfunc(12, '', null=None, snowman='')"
self.assertEquals(
job.description,
test_string,
)
def test_create_empty_job(self): def test_create_empty_job(self):
"""Creation of new empty jobs.""" """Creation of new empty jobs."""
job = Job() job = Job()

Loading…
Cancel
Save