Just setting the attribute won’t change anything, since self.data and self.target was already loaded as seen in these lines of code 2.
You would therefore have to implement a new method which reloads the test/train data, which would basically be another call to __init__.
In my opinion, you should definitely create separate train and test datasets, as even using separate datasets you often encounter code with data leakage.
Also the training and test transformation often differ, which you would also have to pass again to the custom method.