Your templates are not being rendered when the e-mails are sent. The output is rendered only when you test the Mailing; it is then customized per Contact by the Mailer service when each individual e-mail is generated.
This ensures that what you have tested is exactly what you will send -- even if someone goes and changes the templates, pages, or content after the test.
So you cannot determine it programmatically. But there might be a simpler solution: test it using Contacts that have specific test data in them. That way it is obvious that it is a test e-mail -- and you also get to verify that your e-mail looks good with different kinds of data.
To do so, use a static Distribution List of test Contacts instead of just entering e-mail address(es) in the Test Mailing dialog.