Which version of the Revit you use will impact how you call this out of the box. 2026 will differ from 2025 will differ from 2024 will differ from 2023 all based on the Python engine you’re using in each build (it has to update release to release for security reasons and to enable new features) and the .NET and Revit API changes.
So… which Revit version are you in?
Often it helps out output the list of things you can do with the object you have by commenting out the line which is causing the error (i.e. ws_table.RenameWorkset(doc, ws.Id, "test_name")) and concule the script with the directory of actions performable (i.e. OUT = dir(ws_table))