]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-detect-init: fix py3 test 7025/head
authorKefu Chai <kchai@redhat.com>
Wed, 23 Dec 2015 06:36:39 +0000 (14:36 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 23 Dec 2015 08:35:12 +0000 (16:35 +0800)
* in python3, None can not be compared with a str. and
  we should always set codename with a non empty str, so update
  TestCephDetectInit.test_debian so it always set a code name.
  and assert(codename and distroname) in choose_init().

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/ceph-detect-init/ceph_detect_init/debian/__init__.py
src/ceph-detect-init/tests/test_all.py

index 59b47816f470161d53272a94b854ed0a8e5644a5..b5fc7c774e605b38f509b22570139e77e0f449c1 100644 (file)
@@ -8,6 +8,7 @@ def choose_init():
 
     Returns the name of a init system (upstart, sysvinit ...).
     """
+    assert(distro and codename)
     if distro.lower() in ('ubuntu', 'linuxmint'):
         if codename >= 'vivid':
             return 'systemd'
index 4c408f9b507d5f374203c060d587208c68d8210a..f444eebb9f791c2054e36947f7929dffa74f0d8e 100644 (file)
@@ -44,15 +44,18 @@ class TestCephDetectInit(testtools.TestCase):
         self.assertEqual('sysvinit', centos.choose_init())
 
     def test_debian(self):
-        with mock.patch('ceph_detect_init.debian.distro',
-                        'debian'):
+        with mock.patch.multiple('ceph_detect_init.debian',
+                                 distro='debian',
+                                 codename='wheezy'):
             self.assertEqual('sysvinit', debian.choose_init())
-        with mock.patch('ceph_detect_init.debian.distro',
-                        'ubuntu'):
+        with mock.patch.multiple('ceph_detect_init.debian',
+                                 distro='ubuntu',
+                                 codename='trusty'):
             self.assertEqual('upstart', debian.choose_init())
-            with mock.patch('ceph_detect_init.debian.codename',
-                            'vivid'):
-                self.assertEqual('systemd', debian.choose_init())
+        with mock.patch.multiple('ceph_detect_init.debian',
+                                 distro='ubuntu',
+                                 codename='vivid'):
+            self.assertEqual('systemd', debian.choose_init())
 
     def test_fedora(self):
         with mock.patch('ceph_detect_init.fedora.release',