__main__.py 732 B

12345678910111213141516171819
  1. # Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
  2. # For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
  3. """Be able to execute coverage.py by pointing Python at a working tree."""
  4. import runpy, os
  5. PKG = 'coverage'
  6. try:
  7. run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True)
  8. executed = os.path.splitext(os.path.basename(run_globals['__file__']))[0]
  9. if executed != '__main__': # For Python 2.5 compatibility
  10. raise ImportError(
  11. 'Incorrectly executed %s instead of __main__' % executed
  12. )
  13. except ImportError: # For Python 2.6 compatibility
  14. runpy.run_module('%s.__main__' % PKG, run_name='__main__', alter_sys=True)