← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~adeuring/lazr.jobrunner/use_job_repr_in_logging into lp:lazr.jobrunner

 

Abel Deuring has proposed merging lp:~adeuring/lazr.jobrunner/use_job_repr_in_logging into lp:lazr.jobrunner.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~adeuring/lazr.jobrunner/use_job_repr_in_logging/+merge/98821

Some classes that are dervied from BaseRunnableJob in the Launchpad source code define __repr__(), and repr(job) was used by the old job implementation in log messages.

This change fixes failures in these Launchpad tests:

lp.registry.tests.test_process_job_sources_cronjob.ProcessJobSourceGroupsTest.test_processed
lp.registry.tests.test_process_job_sources_cronjob.ProcessJobSourceTest.test_processed
lp.registry.tests.test_membership_notification_job.MembershipNotificationJobTest

(the first two tests need also an s/DEBUG/INFO / in an assertWhatever() call, but i think it is reasonable to change the log level from DEBUG to INFO.)
-- 
https://code.launchpad.net/~adeuring/lazr.jobrunner/use_job_repr_in_logging/+merge/98821
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~adeuring/lazr.jobrunner/use_job_repr_in_logging into lp:lazr.jobrunner.
=== modified file 'src/lazr/jobrunner/jobrunner.py'
--- src/lazr/jobrunner/jobrunner.py	2012-03-16 18:27:52 +0000
+++ src/lazr/jobrunner/jobrunner.py	2012-03-22 11:51:17 +0000
@@ -144,6 +144,9 @@
     def getOopsVars(self):
         return ()
 
+    def __repr__(self):
+        return self.__class__.__name__
+
 
 class JobRunner:
 
@@ -160,9 +163,7 @@
 
     @staticmethod
     def job_str(job):
-        class_name = job.__class__.__name__
-        ijob_id = job.job_id
-        return '%s (ID %d)' % (class_name, ijob_id)
+        return '%r (ID %d)' % (job, job.job_id)
 
     def runJob(self, job):
         """Attempt to run a job, updating its status as appropriate."""

=== modified file 'src/lazr/jobrunner/tests/test_jobrunner.py'

Follow ups