Permalink
Browse files

As per dlecocq suggestion, check with isinstance( ,basestring), to ca…

…tch both str and unicode. Added test to match.
  • Loading branch information...
1 parent 1186b7a commit ee86b41f85b484dbfdc20f2845ef763aaed9a952 @lantiga lantiga committed Nov 30, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 qless/queue.py
  2. +8 −0 test.py
View
@@ -51,7 +51,7 @@ def __setattr__(self, key, value):
object.__setattr__(self, key, value)
def class_string(self, klass):
- if type(klass) == str:
+ if isinstance(klass,basestring):
return klass
return klass.__module__ + '.' + klass.__name__
View
@@ -2462,6 +2462,14 @@ def test_job_by_string(self):
self.assertRaises(AttributeError, lambda: job.foo)
job['testing'] = 'foo'
self.assertEqual(job['testing'], 'foo')
+
+ def test_job_by_unicode(self):
+ job = self.client.jobs[self.q.put(u'test.BarJob', {})]
+ self.assertTrue(job.jid in str(job))
+ self.assertTrue(job.jid in repr(job))
+ self.assertRaises(AttributeError, lambda: job.foo)
+ job['testing'] = 'foo'
+ self.assertEqual(job['testing'], 'foo')
def test_queue(self):
self.assertRaises(AttributeError, lambda: self.q.foo)

0 comments on commit ee86b41

Please sign in to comment.