Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
step(
StepName.pip_install,
True,
_generate_install_cmd(str(pip_exe), str(setup_py_path.parent), config),
f"Installing {setup_py_path} + deps",
config["test_suite_timeout"],
),
step(
StepName.tests_run,
bool("test_suite" in config and config["test_suite"]),
_generate_test_suite_cmd(coverage_exe, config),
f"Running {config.get('test_suite', '')} tests via coverage",
config["test_suite_timeout"],
),
step(
StepName.analyze_coverage,
bool(
"required_coverage" in config
and config["required_coverage"]
and len(config["required_coverage"]) > 0
),
(str(coverage_exe), "report", "-m"),
f"Analyzing coverage report for {setup_py_path}",
config["test_suite_timeout"],
),
step(
StepName.mypy_run,
bool("run_mypy" in config and config["run_mypy"]),
_generate_mypy_cmd(setup_py_path.parent, mypy_exe, config),
f"Running mypy for {setup_py_path}",
config["test_suite_timeout"],
),
a_step.step_name.value,
err_output,
int(time() - test_run_start_time),
False,
)
except asyncio.TimeoutError as toe:
LOG.debug(f"{setup_py_path} timed out running {a_step.log_message} ({toe})")
a_test_result = test_result(
setup_py_path,
a_step.step_name.value,
f"Timeout during {a_step.log_message}",
a_step.timeout,
True,
)
if a_step.step_name is StepName.analyze_coverage:
cov_report = stdout.decode("utf8") if stdout else ""
if print_cov:
print(f"{setup_py_path}:\n{cov_report}")
if a_step.run_condition:
a_test_result = _analyze_coverage(
venv_path,
setup_py_path,
config["required_coverage"],
cov_report,
stats,
test_run_start_time,
)
# If we've had a failure return
if a_test_result:
return a_test_result, steps_ran
failed_output = "The following files did not meet coverage requirements:\n"
failed_coverage = False
for afile, cov_req in required_cov.items():
try:
cover = coverage_lines[afile].cover
except KeyError:
err = (
"{} has not reported any coverage. Does the file exist? "
"Does it get ran during tests? Remove from setup config.".format(afile)
)
keyerror_runtime = int(time() - test_run_start_time)
return test_result(
setup_py_path,
StepName.analyze_coverage.value,
err,
keyerror_runtime,
False,
)
if cover < cov_req:
failed_coverage = True
failed_output += " {}: {} < {} - Missing: {}\n".format(
afile,
coverage_lines[afile].cover,
cov_req,
coverage_lines[afile].missing,
)
if failed_coverage:
failed_cov_runtime = int(time() - test_run_start_time)