1) Create a new interpreter for Pycharm. Firstly create a file with the following contents. As it is seen as a comment, your user needs NOPASSWD enabed which is explained in the previous posts.
#Python Interpreter for running tests as root
# user needs sudo NOPASSWD enabled
sudo PYTHONPATH=$PYTHONPATH python "$@"
3) Then select the file which is created in step 1, and add that interpreter to Pycharm. Now you have a python interpreter which has root privileges.