You shouldn't.
Code shouldn't be aware that it is being run in a test. Introducing
'if TESTING' branches into code introduces extra complexity into the
code you are trying to test - complexity that, by definition, is
untestable.
If you need to modify a setting for testing purposes, then do the same
thing that the Django test suite does - in your test setUp() method,
modify the value of the setting, then restore the original value
during tearDown().
Yours,
Russ Magee %-)