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
1=== modified file 'bzrlib/commands.py'
2--- bzrlib/commands.py 2010-08-13 07:56:06 +0000
3+++ bzrlib/commands.py 2010-10-08 06:33:45 +0000
4@@ -687,7 +687,12 @@
5
6 self._setup_outf()
7
8- return self.run(**all_cmd_args)
9+ try:
10+ return self.run(**all_cmd_args)
11+ finally:
12+ # reset it, so that other commands run in the same process won't
13+ # inherit state
14+ trace.set_verbosity_level(0)
15
16 def _setup_run(self):
17 """Wrap the defined run method on self with a cleanup.
18
19=== modified file 'bzrlib/tests/__init__.py'
20--- bzrlib/tests/__init__.py 2010-10-08 01:43:13 +0000
21+++ bzrlib/tests/__init__.py 2010-10-08 06:33:45 +0000
22@@ -858,6 +858,10 @@
23 self._track_transports()
24 self._track_locks()
25 self._clear_debug_flags()
26+ # Isolate global verbosity level, to make sure it's reproducible
27+ # between tests. We should get rid of this altogether: bug 656694. --
28+ # mbp 20101008
29+ self.overrideAttr(bzrlib.trace, '_verbosity_level', 0)
30
31 def debug(self):
32 # debug a frame up.
33
34=== modified file 'bzrlib/tests/test_script.py'
35--- bzrlib/tests/test_script.py 2010-09-13 09:00:03 +0000
36+++ bzrlib/tests/test_script.py 2010-10-08 06:33:45 +0000
37@@ -19,6 +19,7 @@
38 commands,
39 osutils,
40 tests,
41+ trace,
42 ui,
43 )
44 from bzrlib.tests import script
45@@ -245,6 +246,15 @@
46 cat dog "chicken" 'dragon'
47 """)
48
49+ def test_verbosity_isolated(self):
50+ """Global verbosity is isolated from commands run in scripts.
51+ """
52+ # see also 656694; we should get rid of global verbosity
53+ self.run_script("""
54+ $ bzr init --quiet a
55+ """)
56+ self.assertEquals(trace.is_quiet(), False)
57+
58
59 class TestCat(script.TestCaseWithTransportAndScript):
60