diff --git a/ChangeLog b/ChangeLog index aa69e1e4b4..7c78811c05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-10-25 Titus Brown + + * scripts/normalize-by-median.py,tests/test_normalize_by_median.py: test + and fix for close of --output file after first input file. + 2015-10-05 Michael R. Crusoe * lib/magic: add file extensions, one media type, and a better comment diff --git a/scripts/normalize-by-median.py b/scripts/normalize-by-median.py index 9be0a138a3..49ddef4153 100755 --- a/scripts/normalize-by-median.py +++ b/scripts/normalize-by-median.py @@ -400,7 +400,7 @@ def main(): # pylint: disable=too-many-branches,too-many-statements write_record(record, outfp) log_info('output in {name}', name=describe_file_handle(outfp)) - if not is_block(outfp): + if not args.single_output_file: outfp.close() # finished - print out some diagnostics. diff --git a/tests/test_normalize_by_median.py b/tests/test_normalize_by_median.py index 6e78fb2e66..d8581403fb 100644 --- a/tests/test_normalize_by_median.py +++ b/tests/test_normalize_by_median.py @@ -847,3 +847,14 @@ def test_diginorm_basic_functionality_5(): 'b/1', 'b/2', 'c/1', 'c/2', 'd/1', 'd/2']), seqs + + +def test_normalize_by_median_outfile_closed_err(): + infile1 = utils.get_test_data('paired-mixed.fa.pe') + infile2 = utils.get_test_data("test-abund-read-2.fa") + outfile = utils.get_temp_filename('outfile_xxx') + script = 'normalize-by-median.py' + args = ['-o', outfile, infile1, infile2] + (status, out, err) = utils.runscript(script, args) + assert status == 0, (out, err) + assert os.path.exists(outfile)