You can pass the "now" time into the function which verifies the expiry (and obviously also the function which creates the credentials). The test function calls it with a hard-coded time, and the production function calls it with the actual current time. For example (untested):
def validate_expirycredentials_valid(credentials, now):
return credentials.expiry > now
def test_should_return_false_for_expired_credentials(self):
now = datetime(year=2000, month=1, date=1)
future = now + timedelta(second=1)
credentials = create_credentials(now)
self.assertFalse(credentials_valid(credentials, now))