Пример #1
0
def call(context, fn, *args, **kwargs):
    if configuration.debug.COVERAGE_DIR:
        import coverage
        result = coverage.call(context, fn, *args, **kwargs)
    else:
        result = fn(*args, **kwargs)
    sys.exit(result)
Пример #2
0
def call(context, fn, *args, **kwargs):
    if configuration.debug.COVERAGE_DIR:
        import coverage
        result = coverage.call(context, fn, *args, **kwargs)
    else:
        result = fn(*args, **kwargs)
    sys.exit(result)
Пример #3
0
    def main(environ, start_response):
        import coverage

        def do_process_request(environ, start_response):
            # Apply list() to force the request to be fully performed by this
            # call.  It might return an iterator whose .next() does all the
            # work, and if we just return that from here, the actual work is not
            # subject to coverage measurement.
            return list(process_request(environ, start_response))

        return coverage.call("wsgi", do_process_request, environ, start_response)
Пример #4
0
    except api.repository.InvalidRepositoryName:
        pass
    except Exception as error:
        assert False, "wrong exception raised: %s" % error
    else:
        assert False, "no exception raised"

    try:
        api.repository.fetch(critic, path="/var/git/wrong.git")
    except api.repository.InvalidRepositoryPath:
        pass
    except Exception as error:
        assert False, "wrong exception raised: %s" % error
    else:
        assert False, "no exception raised"


if __name__ == "__main__":
    import coverage

    for arg in sys.argv[1:]:
        if arg.startswith("--sha1="):
            SHA1 = arg[len("--sha1="):]
        if arg.startswith("--head="):
            HEAD = arg[len("--head="):]
        if arg.startswith("--path="):
            PATH = arg[len("--path="):]

    if "basic" in sys.argv[1:]:
        coverage.call("unittest", basic)
Пример #5
0
    assert commit.committer.email == COMMIT_COMMITTER_EMAIL, \
        commit.committer.email
    assert isinstance(commit.committer.timestamp, datetime.datetime), \
        type(commit.committer.timestamp)
    assert commit.committer.timestamp == COMMIT_COMMITTER_TS, \
        commit.committer.timestamp

    try:
        api.commit.fetch(repository, commit_id=47114711)
    except api.commit.InvalidCommitId:
        pass
    except Exception as error:
        assert False, "wrong exception raised: %s" % error
    else:
        assert False, "no exception raised"

    try:
        api.commit.fetch(repository, sha1="".join(reversed(COMMIT_SHA1)))
    except api.commit.InvalidSHA1:
        pass
    except Exception as error:
        assert False, "wrong exception raised: %s" % error
    else:
        assert False, "no exception raised"

if __name__ == "__main__":
    import coverage

    if "basic" in sys.argv[1:]:
        coverage.call("unittest", basic)
Пример #6
0
            result = "%s\n%s\n\n" % (header, "=" * len(header))
            for error in errors:
                result += str(error) + "\n\n"
            for warning in warnings:
                result += str(warning) + "\n\n"

            return [result]
    else:
        try:
            import configuration

            if configuration.debug.COVERAGE_DIR:
                import coverage
                def import_critic():
                    import critic
                coverage.call("wsgi", import_critic)

            import critic
        except ImportError:
            import traceback
            import sys

            exc_info = sys.exc_info()

            def application(environ, start_response):
                start_response("500 Internal Server Error",
                               [("Content-Type", "text/plain")])
                header = "Failed to import 'critic' module"
                return (["%s\n%s\n\n" % (header, "=" * len(header))] +
                        traceback.format_exception(*exc_info))
        else:
Пример #7
0
    assert visualTabs.repository is None

    # Read per-repository, overridden per user.
    visualTabs = alice.getPreference("commit.diff.visualTabs",
                                     repository=repository)
    assert visualTabs.value is True
    assert visualTabs.user is alice
    assert visualTabs.repository is None

    # Read per-user, overridden per repository.
    expandAllFiles = alice.getPreference("commit.expandAllFiles")
    assert expandAllFiles.value is False
    assert expandAllFiles.user is None
    assert expandAllFiles.repository is None

    # Read per-repository, overridden per repository.
    expandAllFiles = alice.getPreference("commit.expandAllFiles",
                                         repository=repository)
    assert expandAllFiles.value is True
    assert expandAllFiles.user is alice
    assert expandAllFiles.repository is repository


if __name__ == "__main__":
    import coverage

    if "basic" in sys.argv[1:]:
        coverage.call("unittest", basic)
    if "preferences" in sys.argv[1:]:
        coverage.call("unittest", preferences)
Пример #8
0
    assert visualTabs.user is alice
    assert visualTabs.repository is None

    # Read per-repository, overridden per user.
    visualTabs = alice.getPreference("commit.diff.visualTabs",
                                     repository=repository)
    assert visualTabs.value is True
    assert visualTabs.user is alice
    assert visualTabs.repository is None

    # Read per-user, overridden per repository.
    expandAllFiles = alice.getPreference("commit.expandAllFiles")
    assert expandAllFiles.value is False
    assert expandAllFiles.user is None
    assert expandAllFiles.repository is None

    # Read per-repository, overridden per repository.
    expandAllFiles = alice.getPreference("commit.expandAllFiles",
                                         repository=repository)
    assert expandAllFiles.value is True
    assert expandAllFiles.user is alice
    assert expandAllFiles.repository is repository

if __name__ == "__main__":
    import coverage

    if "basic" in sys.argv[1:]:
        coverage.call("unittest", basic)
    if "preferences" in sys.argv[1:]:
        coverage.call("unittest", preferences)
Пример #9
0
if arguments.coverage:
    from coverage import call
else:
    def call(_, fn, *args, **kwargs):
        fn(*args, **kwargs)

def execute(path, argv):
    """Load |path| and call main() in it with |argv| as arguments

       If there is no main(), instead assume that each argument in |argv| is the
       name of a test, and run each test by calling a function named the same as
       the test, with no arguments."""

    module = {}
    execfile(path, module)
    if "main" in module:
        module["main"](argv)
        return

    for test in argv:
        if test in module:
            module[test]()

try:
    call("unittest", execute, arguments.test_module, arguments.test_arguments)
    sys.exit(0)
except Exception:
    import traceback
    traceback.print_exc()
    sys.exit(1)
Пример #10
0
                result += str(error) + "\n\n"
            for warning in warnings:
                result += str(warning) + "\n\n"

            return [result]
    else:
        try:
            import configuration

            if configuration.debug.COVERAGE_DIR:
                import coverage

                def import_critic():
                    import critic

                coverage.call("wsgi", import_critic)

            import critic
        except ImportError:
            import traceback
            import sys

            exc_info = sys.exc_info()

            def application(environ, start_response):
                start_response("500 Internal Server Error",
                               [("Content-Type", "text/plain")])
                header = "Failed to import 'critic' module"
                return (["%s\n%s\n\n" % (header, "=" * len(header))] +
                        traceback.format_exception(*exc_info))
        else: