i know it will fail if the light is on, but i don't know about in memory.
d/c the battery should have erased the codes. the codes in memory will be erased after a certain number of starts, too - so if you have some time before the test the problem will likely take care of itself. if you have a code reader that will clear the codes, do that. if you bought the replacement part at a local store that reads the codes for free, bring the car there and ask them to check/erase the code.
lastly, call your states emission test department and ask them, the regs vary by state.