Merge lp:~sylvain-pineau/checkbox/fix-trusty-ppa-build into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 3972
Merged at revision: 3974
Proposed branch: lp:~sylvain-pineau/checkbox/fix-trusty-ppa-build
Merge into: lp:checkbox
Diff against target: 42 lines (+14/-3)
1 file modified
plainbox/plainbox/impl/test_init.py (+14/-3)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/fix-trusty-ppa-build
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Review via email: mp+269747@code.launchpad.net

Description of the change

Fix our 14.04 ppa build to work around the RuntimeError: dictionary changed size during iteration with sys.modules.

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/impl/test_init.py'
2--- plainbox/plainbox/impl/test_init.py 2014-06-16 22:11:02 +0000
3+++ plainbox/plainbox/impl/test_init.py 2015-09-01 13:02:13 +0000
4@@ -24,6 +24,7 @@
5 """
6
7 from unittest import TestCase
8+import warnings
9
10 from plainbox.impl import _get_doc_margin
11 from plainbox.impl import deprecated
12@@ -48,6 +49,13 @@
13 Tests for the @deprecated function decorator
14 """
15
16+ def assertWarns(self, warning, callable, *args, **kwds):
17+ with warnings.catch_warnings(record=True) as warning_list:
18+ warnings.simplefilter('always')
19+ result = callable(*args, **kwds)
20+ self.assertTrue(any(item.category == warning for item in warning_list))
21+ return result, warning_list
22+
23 def test_func_deprecation_warning(self):
24 """
25 Ensure that @deprecated decorator makes functions emit deprecation
26@@ -57,10 +65,13 @@
27 def func():
28 return "value"
29
30- with self.assertWarns(DeprecationWarning) as oops:
31- self.assertEqual(func(), "value")
32+ result, warning_list = self.assertWarns(
33+ DeprecationWarning,
34+ func,
35+ )
36+ self.assertEqual(result, "value")
37 # NOTE: we need to use str() as warnings API is a bit silly there
38- self.assertEqual(str(oops.warning),
39+ self.assertEqual(str(warning_list[0].message),
40 'func is deprecated since version 0.6')
41
42 def test_func_docstring(self):

Subscribers

People subscribed via source and target branches