BUG: Fix wrong variable in test_build.py exception.

The variable used was not defined, causing an error when the exception
was raised.

Closes #3146.