make self_test not import if pytest is not installed
put pytest import inside main() function
actually remove the top level pytest import...
move import out of function while maintaining behaviour
Merge pull request #739 from Cadair/pytest_patch

self_test will throw an ImportError if pytest is not installed