Not how you describe. The usual way is to os.chdir(path_A) within ipython first, or just run path_A/test.py as Thomas said in the comments.
Adding the PYTHONPATH environment variable, as suggested in another answer here, will not work for run because this is only used for searching for import modules.
An alternative, is to put path_A into sys.path (you can do so using PYTHONPATH environment variable, or preferably, in the ipython config file which runs at startup). Then you would be able to do:
import test test.main()
This method would necessitate you to restructure your code in test.py, so that it ran at call time rather than at import time.
cd path_Awithin IPython. Or specifyrun path_A/test.py. I can't think of another option off the top of my head.