Merge lp:~mbp/bzr/656694-verbosity into lp:bzr

Proposed by Martin Pool
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5473
Proposed branch: lp:~mbp/bzr/656694-verbosity
Merge into: lp:bzr
Diff against target: 59 lines (+20/-1)
3 files modified
bzrlib/commands.py (+6/-1)
bzrlib/tests/__init__.py (+4/-0)
bzrlib/tests/test_script.py (+10/-0)
To merge this branch: bzr merge lp:~mbp/bzr/656694-verbosity
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+37933@code.launchpad.net

Commit message

reset global verbosity after each command and test

Description of the change

In the course of lp:~mbp/bzr/scripts I hit some trouble with verbosity not being isolated across tests. We should really get rid of it per bug 656694, but this at least removes the test coupling.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) :
review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/commands.py'
--- bzrlib/commands.py 2010-08-13 07:56:06 +0000
+++ bzrlib/commands.py 2010-10-08 06:33:45 +0000
@@ -687,7 +687,12 @@
687687
688 self._setup_outf()688 self._setup_outf()
689689
690 return self.run(**all_cmd_args)690 try:
691 return self.run(**all_cmd_args)
692 finally:
693 # reset it, so that other commands run in the same process won't
694 # inherit state
695 trace.set_verbosity_level(0)
691696
692 def _setup_run(self):697 def _setup_run(self):
693 """Wrap the defined run method on self with a cleanup.698 """Wrap the defined run method on self with a cleanup.
694699
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2010-10-08 01:43:13 +0000
+++ bzrlib/tests/__init__.py 2010-10-08 06:33:45 +0000
@@ -858,6 +858,10 @@
858 self._track_transports()858 self._track_transports()
859 self._track_locks()859 self._track_locks()
860 self._clear_debug_flags()860 self._clear_debug_flags()
861 # Isolate global verbosity level, to make sure it's reproducible
862 # between tests. We should get rid of this altogether: bug 656694. --
863 # mbp 20101008
864 self.overrideAttr(bzrlib.trace, '_verbosity_level', 0)
861865
862 def debug(self):866 def debug(self):
863 # debug a frame up.867 # debug a frame up.
864868
=== modified file 'bzrlib/tests/test_script.py'
--- bzrlib/tests/test_script.py 2010-09-13 09:00:03 +0000
+++ bzrlib/tests/test_script.py 2010-10-08 06:33:45 +0000
@@ -19,6 +19,7 @@
19 commands,19 commands,
20 osutils,20 osutils,
21 tests,21 tests,
22 trace,
22 ui,23 ui,
23 )24 )
24from bzrlib.tests import script25from bzrlib.tests import script
@@ -245,6 +246,15 @@
245cat dog "chicken" 'dragon'246cat dog "chicken" 'dragon'
246""")247""")
247248
249 def test_verbosity_isolated(self):
250 """Global verbosity is isolated from commands run in scripts.
251 """
252 # see also 656694; we should get rid of global verbosity
253 self.run_script("""
254 $ bzr init --quiet a
255 """)
256 self.assertEquals(trace.is_quiet(), False)
257
248258
249class TestCat(script.TestCaseWithTransportAndScript):259class TestCat(script.TestCaseWithTransportAndScript):
250260