Merge lp:~vila/bzr/1514210-config-test-failures into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Richard Wilbur
Approved revision: no longer in the source branch.
Merged at revision: 6608
Proposed branch: lp:~vila/bzr/1514210-config-test-failures
Merge into: lp:bzr
Diff against target: 143 lines (+24/-20)
2 files modified
bzrlib/tests/test_config.py (+18/-17)
doc/en/release-notes/bzr-2.7.txt (+6/-3)
To merge this branch: bzr merge lp:~vila/bzr/1514210-config-test-failures
Reviewer Review Type Date Requested Status
Richard Wilbur Approve
Review via email: mp+282591@code.launchpad.net

Commit message

Rename assertWarns in test_config to avoid clashing with unittest2 assertWarns.

Description of the change

Thanks Jelmer for reporting the issue and sorry it took so long to look at it :-/

It appears that recent python have switched to unittest2 which introduces a new assertWarns method.

The test_config tests were defining some helpers in a mixin, one of which was also named assertWarns but with a completely different intent and signature.

Thanks to multiple inheritance python now chose the base class method now and not the mixin one.

I've fixed it by getting rid of the mixin in favour of a base class and renaming assertWarns and assertErrors for good measure.

To post a comment you must log in.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Good fix, Vincent.
+2

review: Approve
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/tests/test_config.py'
2--- bzrlib/tests/test_config.py 2014-02-14 10:29:49 +0000
3+++ bzrlib/tests/test_config.py 2016-01-14 14:15:28 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2005-2012 Canonical Ltd
6+# Copyright (C) 2005-2014, 2016 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10@@ -2306,13 +2306,14 @@
11 self.assertEquals('foo', opt.get_help_topic())
12
13
14-class TestOptionConverterMixin(object):
15+class TestOptionConverter(tests.TestCase):
16
17 def assertConverted(self, expected, opt, value):
18 self.assertEquals(expected, opt.convert_from_unicode(None, value))
19
20- def assertWarns(self, opt, value):
21+ def assertCallsWarning(self, opt, value):
22 warnings = []
23+
24 def warning(*args):
25 warnings.append(args[0] % args[1:])
26 self.overrideAttr(trace, 'warning', warning)
27@@ -2322,7 +2323,7 @@
28 'Value "%s" is not valid for "%s"' % (value, opt.name),
29 warnings[0])
30
31- def assertErrors(self, opt, value):
32+ def assertCallsError(self, opt, value):
33 self.assertRaises(errors.ConfigOptionValueError,
34 opt.convert_from_unicode, None, value)
35
36@@ -2330,12 +2331,12 @@
37 opt.invalid = None
38 self.assertEquals(None, opt.convert_from_unicode(None, invalid_value))
39 opt.invalid = 'warning'
40- self.assertWarns(opt, invalid_value)
41+ self.assertCallsWarning(opt, invalid_value)
42 opt.invalid = 'error'
43- self.assertErrors(opt, invalid_value)
44-
45-
46-class TestOptionWithBooleanConverter(tests.TestCase, TestOptionConverterMixin):
47+ self.assertCallsError(opt, invalid_value)
48+
49+
50+class TestOptionWithBooleanConverter(TestOptionConverter):
51
52 def get_option(self):
53 return config.Option('foo', help='A boolean.',
54@@ -2355,7 +2356,7 @@
55 self.assertConverted(False, opt, u'False')
56
57
58-class TestOptionWithIntegerConverter(tests.TestCase, TestOptionConverterMixin):
59+class TestOptionWithIntegerConverter(TestOptionConverter):
60
61 def get_option(self):
62 return config.Option('foo', help='An integer.',
63@@ -2373,7 +2374,7 @@
64 self.assertConverted(16, opt, u'16')
65
66
67-class TestOptionWithSIUnitConverter(tests.TestCase, TestOptionConverterMixin):
68+class TestOptionWithSIUnitConverter(TestOptionConverter):
69
70 def get_option(self):
71 return config.Option('foo', help='An integer in SI units.',
72@@ -2382,8 +2383,8 @@
73 def test_convert_invalid(self):
74 opt = self.get_option()
75 self.assertConvertInvalid(opt, u'not-a-unit')
76- self.assertConvertInvalid(opt, u'Gb') # Forgot the int
77- self.assertConvertInvalid(opt, u'1b') # Forgot the unit
78+ self.assertConvertInvalid(opt, u'Gb') # Forgot the value
79+ self.assertConvertInvalid(opt, u'1b') # Forgot the unit
80 self.assertConvertInvalid(opt, u'1GG')
81 self.assertConvertInvalid(opt, u'1Mbb')
82 self.assertConvertInvalid(opt, u'1MM')
83@@ -2398,7 +2399,7 @@
84 self.assertConverted(100, opt, u'100')
85
86
87-class TestListOption(tests.TestCase, TestOptionConverterMixin):
88+class TestListOption(TestOptionConverter):
89
90 def get_option(self):
91 return config.ListOption('foo', help='A list.')
92@@ -2413,7 +2414,7 @@
93 def test_convert_valid(self):
94 opt = self.get_option()
95 # An empty string is an empty list
96- self.assertConverted([], opt, '') # Using a bare str() just in case
97+ self.assertConverted([], opt, '') # Using a bare str() just in case
98 self.assertConverted([], opt, u'')
99 # A boolean
100 self.assertConverted([u'True'], opt, u'True')
101@@ -2423,11 +2424,11 @@
102 self.assertConverted([u'bar'], opt, u'bar')
103
104
105-class TestRegistryOption(tests.TestCase, TestOptionConverterMixin):
106+class TestRegistryOption(TestOptionConverter):
107
108 def get_option(self, registry):
109 return config.RegistryOption('foo', registry,
110- help='A registry option.')
111+ help='A registry option.')
112
113 def test_convert_invalid(self):
114 registry = _mod_registry.Registry()
115
116=== modified file 'doc/en/release-notes/bzr-2.7.txt'
117--- doc/en/release-notes/bzr-2.7.txt 2015-09-06 21:12:17 +0000
118+++ doc/en/release-notes/bzr-2.7.txt 2016-01-14 14:15:28 +0000
119@@ -89,12 +89,12 @@
120 * Handle (minor) incompatible change in python 2.7.6 leading to test
121 failures. Only tests are affected. (Vincent Ladeuil, #1303879)
122
123-* Take python 2.7.6 late (better than never) bugfix in ntpath.py into
124- account. Only tests are affected (Vincent Ladeuil, #1303879).
125-
126 * Remove wrong assumption about how TCP server and client interact when run
127 inside the same process. (Vincent Ladeuil, #1269886).
128
129+* Rename assertWarns in bt.test_config so it doesn't clash with the
130+ assertWarns introduced in recent python (Vincent Ladeuil, #1514210)
131+
132 * Restrict access to '.netrc' in tests or recent python (2.7.5-8) will
133 complain. (Vincent Ladeuil, #1233413)
134
135@@ -102,5 +102,8 @@
136 way to fix them without testing on windows itself.
137 (Vincent Ladeuil, #1451448)
138
139+* Take python 2.7.6 late (better than never) bugfix in ntpath.py into
140+ account. Only tests are affected (Vincent Ladeuil, #1303879).
141+
142 ..
143 vim: tw=74 ft=rst ff=unix