예제 #1
0
 def handle(self, *args, **options):
     from coverage.cmdline import main
     main(['run', "manage.py", "test"])
     if options['url']:
         self.stdout.write('')
     if options['runserver']:
         call_command('runserver')
예제 #2
0
def execute():
    import os
    import sys

    files = None
    if 'combine' not in sys.argv:

        if '--pydev-analyze' in sys.argv:

            #Ok, what we want here is having the files passed through stdin (because
            #there may be too many files for passing in the command line -- we could
            #just pass a dir and make the find files here, but as that's already
            #given in the java side, let's just gather that info here).
            sys.argv.remove('--pydev-analyze')
            try:
                s = input()
            except:
                s = eval(input())
            s = s.replace('\r', '')
            s = s.replace('\n', '')
            files = s.split('|')
            files = [v for v in files if len(v) > 0]

            #Note that in this case we'll already be in the working dir with the coverage files, so, the
            #coverage file location is not passed.

        else:
            #For all commands, the coverage file is configured in pydev, and passed as the first argument
            #in the command line, so, let's make sure this gets to the coverage module.
            os.environ['COVERAGE_FILE'] = sys.argv[1]
            del sys.argv[1]

    try:
        import coverage  #@UnresolvedImport
    except:
        sys.stderr.write('Error: coverage module could not be imported\n')
        sys.stderr.write(
            'Please make sure that the coverage module (http://nedbatchelder.com/code/coverage/)\n'
        )
        sys.stderr.write('is properly installed in your interpreter: %s\n' %
                         (sys.executable, ))

        import traceback
        traceback.print_exc()
        return

    version = tuple(map(int, coverage.__version__.split('.')[:2]))
    if version < (4, 3):
        sys.stderr.write('Error: minimum supported coverage version is 4.3.')
        sys.exit(1)

    #print(coverage.__version__) TODO: Check if the version is a version we support (should be at least 3.4) -- note that maybe the attr is not there.
    from coverage.cmdline import main  #@UnresolvedImport

    if files is not None:
        sys.argv.append('xml')
        sys.argv += files

    main()
def execute():
    import os
    import sys

    files = None
    if 'combine' not in sys.argv:

        if '--pydev-analyze' in sys.argv:

            #Ok, what we want here is having the files passed through stdin (because
            #there may be too many files for passing in the command line -- we could
            #just pass a dir and make the find files here, but as that's already
            #given in the java side, let's just gather that info here).
            sys.argv.remove('--pydev-analyze')
            try:
                s = raw_input()
            except:
                s = input()
            s = s.replace('\r', '')
            s = s.replace('\n', '')
            files = s.split('|')
            files = [v for v in files if len(v) > 0]

            #Note that in this case we'll already be in the working dir with the coverage files, so, the
            #coverage file location is not passed.

        else:
            #For all commands, the coverage file is configured in pydev, and passed as the first argument
            #in the command line, so, let's make sure this gets to the coverage module.
            os.environ['COVERAGE_FILE'] = sys.argv[1]
            del sys.argv[1]

    try:
        import coverage #@UnresolvedImport
    except:
        sys.stderr.write('Error: coverage module could not be imported\n')
        sys.stderr.write('Please make sure that the coverage module (http://nedbatchelder.com/code/coverage/)\n')
        sys.stderr.write('is properly installed in your interpreter: %s\n' % (sys.executable,))

        import traceback;traceback.print_exc()
        return
    
    version = tuple(map(int, coverage.__version__.split('.'))[:2])
    if version < (4, 3):
        sys.stderr.write('Error: minimum supported coverage version is 4.3.\nFound: %s\nLocation: %s' % ('.'.join(str(x) for x in version), coverage.__file__))
        sys.exit(1)

    #print(coverage.__version__) TODO: Check if the version is a version we support (should be at least 3.4) -- note that maybe the attr is not there.
    from coverage.cmdline import main #@UnresolvedImport

    if files is not None:
        sys.argv.append('xml')
        sys.argv += files

    main()
예제 #4
0
    def run(self):
        from coverage.cmdline import main

        tests_dir = os.path.join(working_dir, 'tests', api_name)
        argv = ['run', '--source', api_name, '-m', 'unittest', 'discover', tests_dir]
        rc = main(argv)
        if rc != 0:
            return rc

        argv = ['html', '-d', self.dst_dir]
        return main(argv)
예제 #5
0
def execute():
    import os
    import sys

    files = None
    if "combine" not in sys.argv:

        if "--pydev-analyze" in sys.argv:

            # Ok, what we want here is having the files passed through stdin (because
            # there may be too many files for passing in the command line -- we could
            # just pass a dir and make the find files here, but as that's already
            # given in the java side, let's just gather that info here).
            sys.argv.remove("--pydev-analyze")
            try:
                s = raw_input()
            except:
                s = input()
            s = s.replace("\r", "")
            s = s.replace("\n", "")
            files = s.split("|")
            files = [v for v in files if len(v) > 0]

            # Note that in this case we'll already be in the working dir with the coverage files, so, the
            # coverage file location is not passed.

        else:
            # For all commands, the coverage file is configured in pydev, and passed as the first argument
            # in the command line, so, let's make sure this gets to the coverage module.
            os.environ["COVERAGE_FILE"] = sys.argv[1]
            del sys.argv[1]

    try:
        import coverage  # @UnresolvedImport
    except:
        sys.stderr.write("Error: coverage module could not be imported\n")
        sys.stderr.write("Please make sure that the coverage module (http://nedbatchelder.com/code/coverage/)\n")
        sys.stderr.write("is properly installed in your interpreter: %s\n" % (sys.executable,))

        import traceback

        traceback.print_exc()
        return

    # print(coverage.__version__) TODO: Check if the version is a version we support (should be at least 3.4) -- note that maybe the attr is not there.
    from coverage.cmdline import main  # @UnresolvedImport

    if files is not None:
        sys.argv.append("-r")
        sys.argv.append("-m")
        sys.argv += files

    main()
예제 #6
0
파일: run_coverage.py 프로젝트: nunb/bugvm
if helpers_root:
    sys_path_backup = sys.path
    sys.path = [p for p in sys.path if p != helpers_root]
    from coverage.cmdline import main
    sys.path = sys_path_backup
else:
    from coverage.cmdline import main

coverage_file = os.getenv('PYCHARM_COVERAGE_FILE')
run_cov = os.getenv('PYCHARM_RUN_COVERAGE')
if os.getenv('JETBRAINS_REMOTE_RUN'):
    line = 'LOG: PyCharm: File mapping:%s\t%s\n'
    import tempfile
    (h, new_cov_file) = tempfile.mkstemp(prefix='pycharm-coverage')
    print(line % (coverage_file, new_cov_file))
    print(line %
          (coverage_file + '.syspath.txt', new_cov_file + '.syspath.txt'))
    print(line % (coverage_file + '.xml', new_cov_file + '.xml'))
    coverage_file = new_cov_file

if coverage_file:
    os.environ['COVERAGE_FILE'] = coverage_file
if run_cov:
    a_file = open(coverage_file + '.syspath.txt', mode='w')
    a_file.write(os.getcwd() + "\n")
    for path in sys.path:
        a_file.write(path + "\n")
    a_file.close()
main()
if run_cov:
    main(["xml", "-o", coverage_file + ".xml", "--ignore-errors"])
예제 #7
0
def execute():
    import os
    import sys

    files = None
    if 'combine' not in sys.argv:

        if '--pydev-analyze' in sys.argv:

            # Ok, what we want here is having the files passed through stdin (because
            # there may be too many files for passing in the command line -- we could
            # just pass a dir and make the find files here, but as that's already
            # given in the java side, let's just gather that info here).
            sys.argv.remove('--pydev-analyze')
            s = input()
            s = s.replace('\r', '')
            s = s.replace('\n', '')

            files = []
            invalid_files = []
            for v in s.split('|'):
                if is_valid_py_file(v):
                    files.append(v)
                else:
                    invalid_files.append(v)
            if invalid_files:
                sys.stderr.write('Invalid files not passed to coverage: %s\n' %
                                 ', '.join(invalid_files))

            # Note that in this case we'll already be in the working dir with the coverage files,
            # so, the coverage file location is not passed.

        else:
            # For all commands, the coverage file is configured in pydev, and passed as the first
            # argument in the command line, so, let's make sure this gets to the coverage module.
            os.environ['COVERAGE_FILE'] = sys.argv[1]
            del sys.argv[1]

    try:
        import coverage  # @UnresolvedImport
    except:
        sys.stderr.write('Error: coverage module could not be imported\n')
        sys.stderr.write('Please make sure that the coverage module '
                         '(http://nedbatchelder.com/code/coverage/)\n')
        sys.stderr.write('is properly installed in your interpreter: %s\n' %
                         (sys.executable, ))

        import traceback
        traceback.print_exc()
        return

    if hasattr(coverage, '__version__'):
        version = tuple(map(int, coverage.__version__.split('.')[:2]))
        if version < (4, 3):
            sys.stderr.write(
                'Error: minimum supported coverage version is 4.3.'
                '\nFound: %s\nLocation: %s\n' %
                ('.'.join(str(x) for x in version), coverage.__file__))
            sys.exit(1)
    else:
        sys.stderr.write(
            'Warning: Could not determine version of python module coverage.'
            '\nEnsure coverage version is >= 4.3\n')

    from coverage.cmdline import main  # @UnresolvedImport

    if files is not None:
        sys.argv.append('xml')
        sys.argv += files

    main()
예제 #8
0
from gevent import monkey
monkey.patch_all()
import pymysql
pymysql.install_as_MySQLdb()

from coverage.cmdline import main

main()
예제 #9
0
"""Coverage.py's main entry point."""
import sys
from coverage.cmdline import main
sys.exit(main())
예제 #10
0
import sys
from coverage.cmdline import main

if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))
예제 #11
0
if os.getenv('CREATE_TEMP_COVERAGE_FILE'):
    line = 'LOG: PyCharm: File mapping:%s\t%s\n'
    import tempfile
    (h, new_cov_file) = tempfile.mkstemp(prefix='pycharm-coverage')
    print(line%(coverage_file, new_cov_file))
    print(line%(coverage_file + '.syspath.txt', new_cov_file + '.syspath.txt'))
    print(line%(coverage_file + '.xml', new_cov_file + '.xml'))
    coverage_file = new_cov_file

if coverage_file:
    os.environ['COVERAGE_FILE'] = coverage_file
if run_cov:
    a_file = open(coverage_file + '.syspath.txt', mode='w')
    a_file.write(os.getcwd()+"\n")
    for path in sys.path: a_file.write(path + "\n")
    a_file.close()

argv = []
for arg in sys.argv:
    if arg.startswith('-m'):
        argv.append('-m')
        argv.append(arg[2:])
    else:
        argv.append(arg)
sys.argv = argv

cwd = os.getcwd()
main()
if run_cov:
    os.chdir(cwd)
    main(["xml", "-o", coverage_file + ".xml", "--ignore-errors"])
예제 #12
0
    def run(self) -> int:
        if not self.cov_data:
            return cmdline.main(self.extra_args)

        with utils.coverage_with_data_file(self.cov_data) as coveragerc:
            return cmdline.main(self.coverage_args(coveragerc))
예제 #13
0
def execute():
    import os
    import sys

    files = None
    if 'combine' not in sys.argv:

        if '--pydev-analyze' in sys.argv:

            #Ok, what we want here is having the files passed through stdin (because
            #there may be too many files for passing in the command line -- we could
            #just pass a dir and make the find files here, but as that's already
            #given in the java side, let's just gather that info here).
            sys.argv.remove('--pydev-analyze')
            try:
                s = raw_input()  # @UndefinedVariable
            except:
                s = input()
            s = s.replace('\r', '')
            s = s.replace('\n', '')

            files = []
            invalid_files = []
            for v in s.split('|'):
                if is_valid_py_file(v):
                    files.append(v)
                else:
                    invalid_files.append(v)
            if invalid_files:
                sys.stderr.write('Invalid files not passed to coverage: %s\n'
                                 % ', '.join(invalid_files))

            # Note that in this case we'll already be in the working dir with the coverage files, 
            # so, the coverage file location is not passed.

        else:
            # For all commands, the coverage file is configured in pydev, and passed as the first 
            # argument in the command line, so, let's make sure this gets to the coverage module.
            os.environ['COVERAGE_FILE'] = sys.argv[1]
            del sys.argv[1]

    try:
        import coverage #@UnresolvedImport
    except:
        sys.stderr.write('Error: coverage module could not be imported\n')
        sys.stderr.write('Please make sure that the coverage module '
                         '(http://nedbatchelder.com/code/coverage/)\n')
        sys.stderr.write('is properly installed in your interpreter: %s\n' % (sys.executable,))

        import traceback;traceback.print_exc()
        return

    if hasattr(coverage, '__version__'):
        version = tuple(map(int, coverage.__version__.split('.')[:2]))
        if version < (4, 3):
            sys.stderr.write('Error: minimum supported coverage version is 4.3.'
                             '\nFound: %s\nLocation: %s\n' 
                             % ('.'.join(str(x) for x in version), coverage.__file__))
            sys.exit(1)
    else:
        sys.stderr.write('Warning: Could not determine version of python module coverage.'
                         '\nEnsure coverage version is >= 4.3\n')

    from coverage.cmdline import main #@UnresolvedImport

    if files is not None:
        sys.argv.append('xml')
        sys.argv += files

    main()
예제 #14
0
    for path in sys.path: a_file.write(path + "\n")
    a_file.close()

argv = []
for arg in sys.argv:
    if arg.startswith('-m') and arg[2:]:
        argv.append(arg[2:])
    else:
        argv.append(arg)
sys.argv = argv

cwd = os.getcwd()

run_xml = os.getenv('PYCHARM_RUN_COVERAGE_XML')
argv = ["xml", "-o", coverage_file + ".xml", "--ignore-errors"]
rcfile = cwd + "/.coveragerc"
if os.path.exists(rcfile):
    print("Loading rcfile: %s\n" % rcfile)
    argv += ["--rcfile", rcfile]

if run_xml:
    os.chdir(cwd)
    main(argv)
else:
    try:
        main()
    finally:
        if run_cov:
            os.chdir(cwd)
            main(argv)
예제 #15
0
"""Coverage.py's main entrypoint."""
from coverage.cmdline import main
main()