diff --git a/mutmut/__main__.py b/mutmut/__main__.py
index 6a8bc6a6..843c86af 100644
--- a/mutmut/__main__.py
+++ b/mutmut/__main__.py
@@ -254,14 +254,16 @@ def junitxml(dict_synonyms, suspicious_policy, untested_policy):
@climain.command(context_settings=dict(help_option_names=['-h', '--help']))
@click.option('--dict-synonyms')
+@click.option('-d', '--directory', help='Write the output files to DIR.')
@config_from_file(
dict_synonyms='',
+ directory='html',
)
-def html(dict_synonyms):
+def html(dict_synonyms, directory):
"""
Generate a HTML report of surviving mutants.
"""
- create_html_report(dict_synonyms)
+ create_html_report(dict_synonyms, directory)
sys.exit(0)
diff --git a/mutmut/cache.py b/mutmut/cache.py
index f9c2ca20..5b9259e2 100644
--- a/mutmut/cache.py
+++ b/mutmut/cache.py
@@ -260,12 +260,12 @@ def create_junitxml_report(dict_synonyms, suspicious_policy, untested_policy):
@init_db
@db_session
-def create_html_report(dict_synonyms):
+def create_html_report(dict_synonyms, directory):
mutants = sorted(list(select(x for x in Mutant)), key=lambda x: x.line.sourcefile.filename)
- os.makedirs('html', exist_ok=True)
+ os.makedirs(directory, exist_ok=True)
- with open('html/index.html', 'w') as index_file:
+ with open(join(directory, 'index.html'), 'w') as index_file:
index_file.write('
Mutation testing report
')
index_file.write('Killed %s out of %s mutants' % (len([x for x in mutants if x.status == OK_KILLED]), len(mutants)))
@@ -273,7 +273,7 @@ def create_html_report(dict_synonyms):
index_file.write('File | Total | Killed | % killed | Survived |
')
for filename, mutants in groupby(mutants, key=lambda x: x.line.sourcefile.filename):
- report_filename = join('html', filename)
+ report_filename = join(directory, filename)
mutants = list(mutants)
diff --git a/tests/test_main.py b/tests/test_main.py
index 48194323..feb149e9 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -704,3 +704,16 @@ def test_html_output(surviving_mutants_filesystem):
'File | Total | Killed | % killed | Survived |
'
'foo.py | 2 | 0 | 0.00 | 2 | '
'