Exemplo n.º 1
0
 def pytest_sessionfinish():
     manager.save_json()
     if ARGV["coverage"]:
         coverage_eval = brownie.test.coverage.get_merged_coverage_eval()
         output._print_coverage_totals(project._build, coverage_eval)
         output._save_coverage_report(
             project._build, coverage_eval,
             project._project_path.joinpath("reports"))
     if ARGV["gas"]:
         output._print_gas_profile()
     project.close(False)
Exemplo n.º 2
0
    def pytest_sessionfinish(self):
        """
        Called after whole test run finished, right before returning the exit
        status to the system.

        * Stores test results in `build/tests.json`
        * Generates coverage report and outputs results to console
        * Closes all active projects
        """
        self._sessionfinish("build/tests.json")
        if CONFIG.argv["gas"]:
            output._print_gas_profile()
Exemplo n.º 3
0
def main():
    args = docopt(__doc__)
    _update_argv_from_docopt(args)

    if project.check_for_project():
        active_project = project.load()
        active_project.load_config()
        print(f"{active_project._name} is the active project.")
    else:
        raise ProjectNotFound

    network.connect(ARGV["network"])

    run(args["<filename>"], method_name=args["<function>"] or "main")
    if ARGV["gas"]:
        _print_gas_profile()
Exemplo n.º 4
0
def main():
    args = docopt(__doc__)
    _update_argv_from_docopt(args)

    if project.check_for_project():
        active_project = project.load()
        active_project.load_config()
        print(f"{active_project._name} is the active project.")
    else:
        raise ProjectNotFound

    network.connect(CONFIG.argv["network"])

    path, _ = _get_path(args["<filename>"])
    path_str = path.absolute().as_posix()

    try:
        run(args["<filename>"], method_name=args["<function>"] or "main")
    except Exception as e:
        print(color.format_tb(e))

        if args["--interactive"]:
            frame = next((i.frame for i in inspect.trace()
                          if Path(i.filename).as_posix() == path_str), None)
            if frame is not None:
                globals_dict = {
                    k: v
                    for k, v in frame.f_globals.items()
                    if not k.startswith("__")
                }

                shell = Console(active_project, {
                    **globals_dict,
                    **frame.f_locals
                })
                shell.interact(
                    banner=f"\nInteractive mode enabled. Use quit() to close.",
                    exitmsg="")

    if CONFIG.argv["gas"]:
        _print_gas_profile()
Exemplo n.º 5
0
 def pytest_sessionfinish(self):
     self._sessionfinish("build/tests.json")
     if CONFIG.argv["gas"]:
         output._print_gas_profile()