From 90fcb6c9d0fce43bd70b580bf024d47b3ef98712 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 26 Aug 2013 10:13:34 +0200 Subject: [PATCH] PEP8ify. --- rq/queue.py | 7 +++---- tests/test_job.py | 32 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index 8d78be2..2404eea 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -158,14 +158,13 @@ class Queue(object): meaningful to the import context of the workers) """ if not isinstance(f, string_types) and f.__module__ == '__main__': - raise ValueError( - 'Functions from the __main__ module cannot be processed ' - 'by workers.') + raise ValueError('Functions from the __main__ module cannot be processed ' + 'by workers.') # Detect explicit invocations, i.e. of the form: # q.enqueue(foo, args=(1, 2), kwargs={'a': 1}, timeout=30) timeout = None - description=None + description = None result_ttl = None if 'args' in kwargs or 'kwargs' in kwargs: assert args == (), 'Extra positional arguments cannot be used when using explicit args and kwargs.' # noqa diff --git a/tests/test_job.py b/tests/test_job.py index 899fbce..01e181c 100644 --- a/tests/test_job.py +++ b/tests/test_job.py @@ -88,9 +88,9 @@ class TestJob(RQTestCase): """Fetching jobs.""" # Prepare test self.testconn.hset('rq:job:some_id', 'data', - "(S'tests.fixtures.some_calculation'\nN(I3\nI4\nt(dp1\nS'z'\nI2\nstp2\n.") # noqa + "(S'tests.fixtures.some_calculation'\nN(I3\nI4\nt(dp1\nS'z'\nI2\nstp2\n.") self.testconn.hset('rq:job:some_id', 'created_at', - "2012-02-07 22:13:24+0000") + '2012-02-07 22:13:24+0000') # Fetch returns a job job = Job.fetch('some_id') @@ -110,13 +110,13 @@ class TestJob(RQTestCase): expected_date = strip_milliseconds(job.created_at) stored_date = self.testconn.hget(job.key, 'created_at').decode('utf-8') self.assertEquals( - times.to_universal(stored_date), - expected_date) + times.to_universal(stored_date), + expected_date) # ... and no other keys are stored self.assertEqual( - self.testconn.hkeys(job.key), - [b'created_at']) + self.testconn.hkeys(job.key), + [b'created_at']) def test_persistence_of_typical_jobs(self): """Storing typical jobs.""" @@ -126,13 +126,13 @@ class TestJob(RQTestCase): expected_date = strip_milliseconds(job.created_at) stored_date = self.testconn.hget(job.key, 'created_at').decode('utf-8') self.assertEquals( - times.to_universal(stored_date), - expected_date) + times.to_universal(stored_date), + expected_date) # ... and no other keys are stored self.assertEqual( - sorted(self.testconn.hkeys(job.key)), - [b'created_at', b'data', b'description']) + sorted(self.testconn.hkeys(job.key)), + [b'created_at', b'data', b'description']) def test_store_then_fetch(self): """Store, then fetch.""" @@ -195,12 +195,12 @@ class TestJob(RQTestCase): """Ensure that job's result_ttl is set properly""" job = Job.create(func=say_hello, args=('Lionel',), result_ttl=10) job.save() - job_from_queue = Job.fetch(job.id, connection=self.testconn) + Job.fetch(job.id, connection=self.testconn) self.assertEqual(job.result_ttl, 10) job = Job.create(func=say_hello, args=('Lionel',)) job.save() - job_from_queue = Job.fetch(job.id, connection=self.testconn) + Job.fetch(job.id, connection=self.testconn) self.assertEqual(job.result_ttl, None) def test_description_is_persisted(self): @@ -208,13 +208,13 @@ class TestJob(RQTestCase): description = 'Say hello!' job = Job.create(func=say_hello, args=('Lionel',), description=description) job.save() - job_from_queue = Job.fetch(job.id, connection=self.testconn) + Job.fetch(job.id, connection=self.testconn) self.assertEqual(job.description, description) # Ensure job description is constructed from function call string job = Job.create(func=say_hello, args=('Lionel',)) job.save() - job_from_queue = Job.fetch(job.id, connection=self.testconn) + Job.fetch(job.id, connection=self.testconn) self.assertEqual(job.description, job.get_call_string()) def test_job_access_within_job_function(self): @@ -254,12 +254,12 @@ class TestJob(RQTestCase): """Test that jobs and results are expired properly.""" job = Job.create(func=say_hello) job.save() - + # Jobs with negative TTLs don't expire job.cleanup(ttl=-1) self.assertEqual(self.testconn.ttl(job.key), -1) - # Jobs with positive TTLs are eventually deleted + # Jobs with positive TTLs are eventually deleted job.cleanup(ttl=100) self.assertEqual(self.testconn.ttl(job.key), 100)