← Back to team overview

cloud-init-dev team mailing list archive

[Merge] lp:~harlowja/cloud-init/py26-test-fixage into lp:cloud-init

 

Joshua Harlow has proposed merging lp:~harlowja/cloud-init/py26-test-fixage into lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)

For more details, see:
https://code.launchpad.net/~harlowja/cloud-init/py26-test-fixage/+merge/227098

Fix a few tests that have been failing in python 2.6
-- 
https://code.launchpad.net/~harlowja/cloud-init/py26-test-fixage/+merge/227098
Your team cloud init development team is requested to review the proposed merge of lp:~harlowja/cloud-init/py26-test-fixage into lp:cloud-init.
=== modified file 'tests/unittests/helpers.py'
--- tests/unittests/helpers.py	2014-02-08 00:40:51 +0000
+++ tests/unittests/helpers.py	2014-07-16 20:08:52 +0000
@@ -52,6 +52,30 @@
                 standardMsg = standardMsg % (value)
                 self.fail(self._formatMessage(msg, standardMsg))
 
+        def assertDictContainsSubset(self, expected, actual, msg=None):
+            missing = []
+            mismatched = []
+            for k, v in expected.iteritems():
+                if k not in actual:
+                    missing.append(k)
+                elif actual[k] != v:
+                    mismatched.append('%r, expected: %r, actual: %r'
+                                      % (k, v, actual[k]))
+
+            if len(missing) == 0 and len(mismatched) == 0:
+                return
+
+            standardMsg = ''
+            if missing:
+                standardMsg = 'Missing: %r' % ','.join(m for m in missing)
+            if mismatched:
+                if standardMsg:
+                    standardMsg += '; '
+                standardMsg += 'Mismatched values: %s' % ','.join(mismatched)
+
+            self.fail(self._formatMessage(msg, standardMsg))
+
+
 else:
     class TestCase(unittest.TestCase):
         pass

=== modified file 'tests/unittests/test_datasource/test_cloudsigma.py'
--- tests/unittests/test_datasource/test_cloudsigma.py	2014-05-30 18:50:57 +0000
+++ tests/unittests/test_datasource/test_cloudsigma.py	2014-07-16 20:08:52 +0000
@@ -1,10 +1,11 @@
 # coding: utf-8
 import copy
-from unittest import TestCase
 
 from cloudinit.cs_utils import Cepko
 from cloudinit.sources import DataSourceCloudSigma
 
+from tests.unittests import helpers as test_helpers
+
 
 SERVER_CONTEXT = {
     "cpu": 1000,
@@ -36,7 +37,7 @@
         return self
 
 
-class DataSourceCloudSigmaTest(TestCase):
+class DataSourceCloudSigmaTest(test_helpers.TestCase):
     def setUp(self):
         self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
         self.datasource.is_running_in_cloudsigma = lambda: True

=== modified file 'tests/unittests/test_datasource/test_gce.py'
--- tests/unittests/test_datasource/test_gce.py	2014-02-13 22:03:12 +0000
+++ tests/unittests/test_datasource/test_gce.py	2014-07-16 20:08:52 +0000
@@ -15,7 +15,6 @@
 #    You should have received a copy of the GNU General Public License
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import unittest
 import httpretty
 import re
 
@@ -25,6 +24,8 @@
 from cloudinit import helpers
 from cloudinit.sources import DataSourceGCE
 
+from tests.unittests import helpers as test_helpers
+
 GCE_META = {
     'instance/id': '123',
     'instance/zone': 'foo/bar',
@@ -54,7 +55,7 @@
         return (404, headers, '')
 
 
-class TestDataSourceGCE(unittest.TestCase):
+class TestDataSourceGCE(test_helpers.TestCase):
 
     def setUp(self):
         self.ds = DataSourceGCE.DataSourceGCE(


Follow ups