]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs_test_runner: setattr to class not instance 32571/head
authorKefu Chai <kchai@redhat.com>
Thu, 9 Jan 2020 11:36:37 +0000 (19:36 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 9 Jan 2020 12:48:23 +0000 (20:48 +0800)
before this change, `setattr()` sets the instance specialized with a certain method
of test case, so in `MgrTestCase.setUpClass()`

assert cls.mgr_cluster is not None

fails,

after this change, instead of test case, the class of test suite is updated with the
specified params, even if we pass a certain test to test runner.
so we can

./run-backend-api-tests.sh tasks.mgr.test_dashboard.TestDashboard.test_standby

now. before this change, we can only:

./run-backend-api-tests.sh tasks.mgr.test_dashboard.TestDashboard

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/cephfs_test_runner.py

index 4455c086f31314b4acddb3da792ad34d59e4ba26..8a4919b93fe313cad4a8c28c56541a2753c04f78 100644 (file)
@@ -22,7 +22,11 @@ class DecoratingLoader(loader.TestLoader):
 
     def _apply_params(self, obj):
         for k, v in self._params.items():
-            setattr(obj, k, v)
+            if obj.__class__ is type:
+                cls = obj
+            else:
+                cls = obj.__class__
+            setattr(cls, k, v)
 
     def loadTestsFromTestCase(self, testCaseClass):
         self._apply_params(testCaseClass)