Home | History | Annotate | Download | only in coverage
      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 
      4 """Be able to execute coverage.py by pointing Python at a working tree."""
      5 
      6 import runpy, os
      7 
      8 PKG = 'coverage'
      9 
     10 try:
     11     run_globals = runpy.run_module(PKG, run_name='__main__', alter_sys=True)
     12     executed = os.path.splitext(os.path.basename(run_globals['__file__']))[0]
     13     if executed != '__main__':  # For Python 2.5 compatibility
     14         raise ImportError(
     15             'Incorrectly executed %s instead of __main__' % executed
     16             )
     17 except ImportError:  # For Python 2.6 compatibility
     18     runpy.run_module('%s.__main__' % PKG, run_name='__main__', alter_sys=True)
     19