-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement rosemary coverage command
- Loading branch information
1 parent
a6e26b7
commit c5b9a16
Showing
5 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ uploads/ | |
app.log | ||
.DS_Store | ||
rosemary.egg-info/ | ||
build/ | ||
build/ | ||
.coverage | ||
htmlcov/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import click | ||
import subprocess | ||
import os | ||
|
||
|
||
@click.command('coverage', help="Runs pytest coverage on the blueprints directory or a specific module.") | ||
@click.argument('module_name', required=False) | ||
@click.option('--html', is_flag=True, help="Generates an HTML coverage report.") | ||
def coverage(module_name, html): | ||
base_path = 'app/blueprints' | ||
test_path = base_path | ||
|
||
if module_name: | ||
test_path = os.path.join(base_path, module_name) | ||
if not os.path.exists(test_path): | ||
click.echo(click.style(f"Module '{module_name}' does not exist.", fg='red')) | ||
return | ||
click.echo(f"Running coverage for the '{module_name}' module...") | ||
else: | ||
click.echo("Running coverage for all modules...") | ||
|
||
coverage_cmd = ['pytest', '--cov=' + test_path, test_path] | ||
|
||
if html: | ||
coverage_cmd.extend(['--cov-report', 'html']) | ||
|
||
try: | ||
subprocess.run(coverage_cmd, check=True) | ||
except subprocess.CalledProcessError as e: | ||
click.echo(click.style(f"Error running coverage: {e}", fg='red')) |