Can I take a pregnancy test 6 days before my period?

I had sex on the 31st I know it hasn’t quite been 2 weeks yet but my period is supposed to start in 6 days, can I take a test?