From: Kefu Chai Date: Thu, 9 Jan 2020 11:36:37 +0000 (+0800) Subject: qa/tasks/cephfs_test_runner: setattr to class not instance X-Git-Tag: v15.1.0~275^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F32571%2Fhead;p=ceph.git qa/tasks/cephfs_test_runner: setattr to class not instance 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 --- diff --git a/qa/tasks/cephfs_test_runner.py b/qa/tasks/cephfs_test_runner.py index 4455c086f31..8a4919b93fe 100644 --- a/qa/tasks/cephfs_test_runner.py +++ b/qa/tasks/cephfs_test_runner.py @@ -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)