Fixed Macvim linking with brewed Python + tests

This should fix issue #31901.

I also added a test to both macvim and vim formula to test they link to the correct version of Python
First time coding in ruby so if you have any advice or corrections please let me know!
Just to check: does this pass with and without a Homebrew `python` installed? Thanks!