From e8c19894d6b1f542136f15c274450a83023dae3b Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Wed, 5 May 2021 15:01:51 -0700 Subject: [PATCH 1/7] replaced utils.TempDirectory with run tmp, not working yet --- tests/test_cmd_signature.py | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index f4d16f7099..e98b116458 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -1588,27 +1588,27 @@ def test_import_export_2(c): assert imported.minhash == compare.minhash -def test_import_mash_csv_to_sig(): +def test_import_mash_csv_to_sig(runtmp): # test copied over from 'sourmash import_csv'. - with utils.TempDirectory() as location: - testdata1 = utils.get_test_data('short.fa.msh.dump') - testdata2 = utils.get_test_data('short.fa') - - status, out, err = utils.runscript('sourmash', ['sig', 'import', - '--csv', - testdata1, - '-o', 'xxx.sig'], - in_directory=location) - - status, out, err = utils.runscript('sourmash', - ['compute', '-k', '31', - '-n', '970', testdata2], - in_directory=location) - - status, out, err = utils.runscript('sourmash', - ['search', '-k', '31', - 'short.fa.sig', 'xxx.sig'], - in_directory=location) - print(status, out, err) + testdata1 = runtmp.get_test_data('short.fa.msh.dump') + testdata2 = runtmp.get_test_data('short.fa') + + status, out, err = runtmp.runscript('sourmash', ['sig', 'import', + '--csv', + testdata1, + '-o', 'xxx.sig'], + in_directory=location) + + status, out, err = runtmp.runscript('sourmash', + ['compute', '-k', '31', + '-n', '970', testdata2], + in_directory=location) + + status, out, err = runtmp.runscript('sourmash', + ['search', '-k', '31', + 'short.fa.sig', 'xxx.sig'], + in_directory=location) + print(status, out, err) + assert '1 matches:' in out + assert '100.0% short.fa' in out assert '1 matches:' in out - assert '100.0% short.fa' in out From 7763ada7ccaae5f071393b883ecdc933fcd0e6b0 Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Thu, 6 May 2021 12:41:07 -0700 Subject: [PATCH 2/7] added runner context run.tmp --- tests/test_cmd_signature.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index e98b116458..d9e5484acb 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -1593,22 +1593,22 @@ def test_import_mash_csv_to_sig(runtmp): testdata1 = runtmp.get_test_data('short.fa.msh.dump') testdata2 = runtmp.get_test_data('short.fa') - status, out, err = runtmp.runscript('sourmash', ['sig', 'import', + runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err = runtmp.runscript('sourmash', ['sig', 'import', '--csv', testdata1, '-o', 'xxx.sig'], in_directory=location) - status, out, err = runtmp.runscript('sourmash', + runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err = runtmp.runscript('sourmash', ['compute', '-k', '31', '-n', '970', testdata2], in_directory=location) - status, out, err = runtmp.runscript('sourmash', + runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err = runtmp.runscript('sourmash', ['search', '-k', '31', 'short.fa.sig', 'xxx.sig'], in_directory=location) - print(status, out, err) - assert '1 matches:' in out - assert '100.0% short.fa' in out - assert '1 matches:' in out + print(runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err) + assert '1 matches:' in runtmp.last_result.out + assert '100.0% short.fa' in runtmp.last_result.out + assert '1 matches:' in runtmp.last_result.out From dd606ac6253ec7c65e2cc96602b87a52a914d534 Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Fri, 7 May 2021 09:17:16 -0700 Subject: [PATCH 3/7] updated test_import_mash_csv_to_sig with runtmp fixture --- tests/test_cmd_signature.py | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/tests/test_cmd_signature.py b/tests/test_cmd_signature.py index d9e5484acb..8b3d418e73 100644 --- a/tests/test_cmd_signature.py +++ b/tests/test_cmd_signature.py @@ -1590,25 +1590,16 @@ def test_import_export_2(c): def test_import_mash_csv_to_sig(runtmp): # test copied over from 'sourmash import_csv'. - testdata1 = runtmp.get_test_data('short.fa.msh.dump') - testdata2 = runtmp.get_test_data('short.fa') - - runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err = runtmp.runscript('sourmash', ['sig', 'import', - '--csv', - testdata1, - '-o', 'xxx.sig'], - in_directory=location) - - runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err = runtmp.runscript('sourmash', - ['compute', '-k', '31', - '-n', '970', testdata2], - in_directory=location) - - runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err = runtmp.runscript('sourmash', - ['search', '-k', '31', - 'short.fa.sig', 'xxx.sig'], - in_directory=location) - print(runtmp.last_result.status, runtmp.last_result.out, runtmp.last_result.err) + testdata1 = utils.get_test_data('short.fa.msh.dump') + testdata2 = utils.get_test_data('short.fa') + + runtmp.sourmash('sig', 'import', '--csv', testdata1, '-o', 'xxx.sig') + + runtmp.sourmash('compute', '-k', '31', '-n', '970', testdata2) + + runtmp.sourmash('search', '-k', '31', 'short.fa.sig', 'xxx.sig') + + print("RUNTEMP", runtmp) + assert '1 matches:' in runtmp.last_result.out assert '100.0% short.fa' in runtmp.last_result.out - assert '1 matches:' in runtmp.last_result.out From 18c1b142378828fa0b445673f6512922effd3809 Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Wed, 12 May 2021 15:26:24 -0700 Subject: [PATCH 4/7] replaced "runner context" w runtmp --- tests/test_index.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_index.py b/tests/test_index.py index 2227010eaa..08dcb00136 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -323,7 +323,7 @@ def test_linear_index_search_abund_subj_flat(): assert "'search_abund' requires subject signatures with abundance information" in str(exc.value) -def test_linear_index_save(): +def test_linear_index_save(runtmp): sig2 = utils.get_test_data('2.fa.sig') sig47 = utils.get_test_data('47.fa.sig') sig63 = utils.get_test_data('63.fa.sig') @@ -337,7 +337,7 @@ def test_linear_index_save(): linear.insert(ss47) linear.insert(ss63) - with utils.TempDirectory() as location: + with runtmp as location: filename = os.path.join(location, 'foo') linear.save(filename) From 21de7f103f377b07375ea3d869cb0ce73af9b316 Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Wed, 12 May 2021 16:03:26 -0700 Subject: [PATCH 5/7] updated runner context and working --- tests/test_index.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_index.py b/tests/test_index.py index 08dcb00136..40b60f77d7 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -337,19 +337,18 @@ def test_linear_index_save(runtmp): linear.insert(ss47) linear.insert(ss63) - with runtmp as location: - filename = os.path.join(location, 'foo') - linear.save(filename) + filename = runtmp.output('foo') + linear.save(filename) - si = set(sourmash.load_file_as_signatures(filename)) + si = set(sourmash.load_file_as_signatures(filename)) x = {ss2, ss47, ss63} print(len(si)) print(len(x)) - print(si) - print(x) + print('si: ', si) + print('x: ', x) assert si == x, si From 88cfc1a780890d790f384aa7ebf24b50f0c09668 Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Wed, 12 May 2021 16:35:17 -0700 Subject: [PATCH 6/7] added runtmp to test_linear_index_save, wrking --- tests/test_index.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_index.py b/tests/test_index.py index 40b60f77d7..831b35cdf4 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -353,7 +353,7 @@ def test_linear_index_save(runtmp): assert si == x, si -def test_linear_index_load(): +def test_linear_index_load(runtmp): sig2 = utils.get_test_data('2.fa.sig') sig47 = utils.get_test_data('47.fa.sig') sig63 = utils.get_test_data('63.fa.sig') @@ -362,14 +362,13 @@ def test_linear_index_load(): ss47 = sourmash.load_one_signature(sig47) ss63 = sourmash.load_one_signature(sig63) - with utils.TempDirectory() as location: - from sourmash import save_signatures - - filename = os.path.join(location, 'foo') - with open(filename, 'wt') as fp: - sourmash.save_signatures([ss2, ss47, ss63], fp) + from sourmash import save_signatures + + filename = runtmp.output('foo') + with open(filename, 'wt') as fp: + sourmash.save_signatures([ss2, ss47, ss63], fp) - linear = LinearIndex.load(filename) + linear = LinearIndex.load(filename) x = {ss2, ss47, ss63} assert set(linear.signatures()) == x, linear.signatures From c1d1c27dd44842f2bbfa227d5918167cd62fbfa8 Mon Sep 17 00:00:00 2001 From: "Hannah E. Houts" Date: Wed, 12 May 2021 17:03:59 -0700 Subject: [PATCH 7/7] added runtmp to test_linear_index_save_load, wrkng --- tests/test_index.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/test_index.py b/tests/test_index.py index 831b35cdf4..c762d4369b 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -375,7 +375,7 @@ def test_linear_index_load(runtmp): assert linear.location == filename -def test_linear_index_save_load(): +def test_linear_index_save_load(runtmp): sig2 = utils.get_test_data('2.fa.sig') sig47 = utils.get_test_data('47.fa.sig') sig63 = utils.get_test_data('63.fa.sig') @@ -388,11 +388,10 @@ def test_linear_index_save_load(): linear.insert(ss2) linear.insert(ss47) linear.insert(ss63) - - with utils.TempDirectory() as location: - filename = os.path.join(location, 'foo') - linear.save(filename) - linear2 = LinearIndex.load(filename) + + filename = runtmp.output('foo') + linear.save(filename) + linear2 = LinearIndex.load(filename) # now, search for sig2 sr = linear2.search(ss2, threshold=1.0)