[Dev] Getting ready for run_tests
Phillip J. Eby
pje at telecommunity.com
Tue Jun 7 11:06:12 PDT 2005
Then I'll commit it later today if noone objects.
At 10:28 AM 6/7/2005 -0700, Ted Leung wrote:
>+1 to all the below...
>
>Ted
>
>On Jun 6, 2005, at 7:49 PM, Phillip J. Eby wrote:
>
>>At 05:14 PM 6/6/2005 -0700, Ted Leung wrote:
>>
>>>For those of you that don't know, PJE has written 'run_tests', which
>>>is a flexible driver for running the unit tests. If you are
>>>interested in using it, you can type
>>>'RunPython -m run_tests' in $CHANDLERHOME and it will display its
>>>manual. We're not quite ready to switch over to run_tests as the
>>>official method of running the tests (there are one or two issues
>>>that need to be ironed out), but it's there if you are interested in
>>>trying it.
>>>
>>>I have a small patch to RepositoryTestCase that turns of the
>>>repository commit log messages. This makes running the unit tests
>>>under 'run_tests' a much more pleasant experience.
>>>
>>>I've attached the patch below, if no one objects, I'll commit it late
>>>tomorrow (Tuesday)
>>
>>May I suggest logger.WARNING instead of critical? The repository
>>commit messages are at level INFO, so that will suppress purely-
>>informational log messages without suppressing warnings or errors
>>that might be useful for debugging. I did a quick search for uses
>>of the warning and error level messages in the repository.*
>>packages, and the only use that was even remotely questionable was
>>a warning about notifications taking longer than a second, that
>>I've never seen happen in practice.
>>
>>I'm also not sure if there need to be three places where the log
>>level gets set; I think it's reasonable for RepositoryTestCase to
>>set its own repository's logger level to WARNING, but I'm not sure
>>the module should be messing with the root logger level. Global
>>log configuration seems more like a job for the test runner than
>>the test cases.
>>
>>By the way, I don't believe you need to have the 'stderr=False'
>>change. All that the 'stderr' flag does in the repository is tell
>>it whether to add a dummy handler to the root logger. It has no
>>actual effect on the level of log suppression.
>>
>>So, here's an alternative patch proposal. It changes less, but
>>still succeeds in suppressing the commit messages, and also allows
>>individual test case classes to set their own log levels, if they
>>want to raise or lower it for some reason:
>>
>>
>>Index: repository/tests/RepositoryTestCase.py
>>===================================================================
>>--- repository/tests/RepositoryTestCase.py (revision 5605)
>>+++ repository/tests/RepositoryTestCase.py (working copy)
>>@@ -20,6 +20,8 @@
>>
>> class RepositoryTestCase(TestCase):
>>
>>+ logLevel = logging.WARNING # a nice quiet default
>>+
>> def _setup(self, ramdb=True):
>> schema.reset()
>> self.rootdir = os.environ['CHANDLERHOME']
>>@@ -46,14 +48,13 @@
>> self.ramdb = False
>> self.rep.open(ramdb=False,
>> fromPath=preloadedRepositoryPath,
>>- stderr=True,
>> refcounted=True)
>>+ self.rep.logger.setLevel(self.logLevel)
>> self.rep.logger.info('Using preloaded repository')
>> else:
>> self.rep.create(ramdb=self.ramdb,
>>- stderr=True,
>> refcounted=True)
>>-
>>+ self.rep.logger.setLevel(self.logLevel)
>> self.rep.loadPack(self.schemaPack)
>> self.rep.loadPack(self.chandlerPack)
>> self.rep.commit()
>>
>>
>>Of course, this doesn't do anything about the 186 print statements
>>currently in Chandler and its tests (not counting commented-out
>>print statements), so they can still produce quite a bit of spew.
>>
>
>----
>Ted Leung Open Source Applications Foundation (OSAF)
>PGP Fingerprint: 1003 7870 251F FA71 A59A CEE3 BEBA 2B87 F5FC 4B42
>
More information about the Dev
mailing list