You need to source hacking/env-setup before running hacking/test-module; otherwise you get an error like this: ImportError: No module named ansible.utils