It isn’t raised in the middle of testing the hash.  The testing is completely done in the Argon2 C library and the bindings raise an error if it returns an error.  The Python library doesn’t do anything smart at all except calling C functions on strings.