You can use the cherry-pick
command if you know the exact commit in your "master" branch that changed file.py:
git checkout test
git cherry-pick COMMIT_SHA
Otherwise you can do something like:
git checkout test
git checkout master -- file.py
git commit -m "Your message"
Edit: I had the branches mixed up. I corrected them.