From 204263b829bf33a15763d25826494dd3d66620ec Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 9 Jan 2020 19:36:37 +0800 Subject: [PATCH] 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 --- qa/tasks/cephfs_test_runner.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qa/tasks/cephfs_test_runner.py b/qa/tasks/cephfs_test_runner.py index 4455c086f3131..8a4919b93fe31 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) -- 2.47.3