Everybody replying to you that this is fragile is missing the point. This kind of code isn't the first line of defense—it's the last.
For instance, test code shouldn't have access to production DB passwords. Maybe that means a slightly less convenient login for the dev to get to production, but it's worth it.