Merge lp:~vila/bzr/test-fixes into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: not available
Merged at revision: 6524
Proposed branch: lp:~vila/bzr/test-fixes
Merge into: lp:bzr
Diff against target: 43 lines (+6/-2)
2 files modified
bzrlib/config.py (+2/-1)
bzrlib/tests/test_config.py (+4/-1)
To merge this branch: bzr merge lp:~vila/bzr/test-fixes
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+105940@code.launchpad.net

Commit message

Fix some test isolation issues when random env vars are used.

Description of the change

This fix some issues in config and its tests raised by mgz.

I will land this but wanted to highlight the isolation issue regarding env
vars: using random env vars in tests is fine but we don't get isolation from
our test framework for them so we have to handle it explicitly.

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) 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/config.py'
2--- bzrlib/config.py 2012-03-29 12:27:52 +0000
3+++ bzrlib/config.py 2012-05-16 09:06:18 +0000
4@@ -2398,7 +2398,8 @@
5 value = self.default()
6 if not isinstance(value, unicode):
7 raise AssertionError(
8- 'Callable default values should be unicode')
9+ "Callable default value for '%s' should be unicode"
10+ % (self.name))
11 else:
12 value = self.default
13 return value
14
15=== modified file 'bzrlib/tests/test_config.py'
16--- bzrlib/tests/test_config.py 2012-03-29 12:27:52 +0000
17+++ bzrlib/tests/test_config.py 2012-05-16 09:06:18 +0000
18@@ -2477,7 +2477,6 @@
19
20 def test_help_is_set(self):
21 option_help = self.registry.get_help(self.option_name)
22- self.assertNotEquals(None, option_help)
23 # Come on, think about the user, he really wants to know what the
24 # option is about
25 self.assertIsNot(None, option_help)
26@@ -3584,6 +3583,7 @@
27 return config.MemoryStack(content)
28
29 def test_override_value_from_env(self):
30+ self.overrideEnv('FOO', None)
31 self.registry.register(
32 config.Option('foo', default='bar', override_from_env=['FOO']))
33 self.overrideEnv('FOO', 'quux')
34@@ -3592,6 +3592,9 @@
35 self.assertEquals('quux', conf.get('foo'))
36
37 def test_first_override_value_from_env_wins(self):
38+ self.overrideEnv('NO_VALUE', None)
39+ self.overrideEnv('FOO', None)
40+ self.overrideEnv('BAZ', None)
41 self.registry.register(
42 config.Option('foo', default='bar',
43 override_from_env=['NO_VALUE', 'FOO', 'BAZ']))