From 08f45a5932b173e9c51f8a68f30580a9bf2006f4 Mon Sep 17 00:00:00 2001 From: EricMichaelSmith Date: Tue, 12 Jan 2021 15:43:45 -0500 Subject: [PATCH 1/2] Allow substring --- .../test_turn_annotations_static_analysis.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py b/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py index fabb3674405..24ead18b1ca 100644 --- a/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py +++ b/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py @@ -137,7 +137,9 @@ def test_compile_results(self): """ actual_stdout_lines = actual_stdout.split('\n') for desired_line in desired_stdout.split('\n'): - if desired_line not in actual_stdout_lines: + if not any( + desired_line in actual_line for actual_line in actual_stdout_lines + ): raise ValueError( f'\n\tThe following line:\n\n{desired_line}\n\n\twas not found ' f'in the actual stdout:\n\n{actual_stdout}' From d055541d7a0b69cbf049463df2ac7558ec4395b9 Mon Sep 17 00:00:00 2001 From: EricMichaelSmith Date: Tue, 12 Jan 2021 15:53:09 -0500 Subject: [PATCH 2/2] Name change --- ...sired_results.csv => expected_results.csv} | 0 .../test_turn_annotations_static_analysis.py | 22 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) rename tests/crowdsourcing/tasks/turn_annotations_static/analysis_config/{desired_results.csv => expected_results.csv} (100%) diff --git a/tests/crowdsourcing/tasks/turn_annotations_static/analysis_config/desired_results.csv b/tests/crowdsourcing/tasks/turn_annotations_static/analysis_config/expected_results.csv similarity index 100% rename from tests/crowdsourcing/tasks/turn_annotations_static/analysis_config/desired_results.csv rename to tests/crowdsourcing/tasks/turn_annotations_static/analysis_config/expected_results.csv diff --git a/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py b/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py index 24ead18b1ca..73c67ba1a4d 100644 --- a/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py +++ b/tests/crowdsourcing/tasks/turn_annotations_static/test_turn_annotations_static_analysis.py @@ -31,7 +31,7 @@ def test_compile_results(self): with testing_utils.tempdir() as tmpdir: - # Define desired stdout + # Define expected stdout # Paths analysis_config_folder = os.path.join( @@ -100,7 +100,7 @@ def test_compile_results(self): actual_stdout = output.getvalue() # Check the output against what it should be - desired_stdout = f"""\ + expected_stdout = f"""\ Got 4 folders to read. Average task completion time (seconds) was: 187.5 Returning master dataframe with 48 annotations. @@ -136,22 +136,22 @@ def test_compile_results(self): Fleiss' kappa for none_all_good is: -0.410.\ """ actual_stdout_lines = actual_stdout.split('\n') - for desired_line in desired_stdout.split('\n'): + for expected_line in expected_stdout.split('\n'): if not any( - desired_line in actual_line for actual_line in actual_stdout_lines + expected_line in actual_line for actual_line in actual_stdout_lines ): raise ValueError( - f'\n\tThe following line:\n\n{desired_line}\n\n\twas not found ' + f'\n\tThe following line:\n\n{expected_line}\n\n\twas not found ' f'in the actual stdout:\n\n{actual_stdout}' ) # Check that the saved results file is what it should be sort_columns = ['hit_id', 'worker_id', 'conversation_id', 'turn_idx'] - desired_results_path = os.path.join( - analysis_config_folder, 'desired_results.csv' + expected_results_path = os.path.join( + analysis_config_folder, 'expected_results.csv' ) - desired_results = ( - pd.read_csv(desired_results_path) + expected_results = ( + pd.read_csv(expected_results_path) .drop('folder', axis=1) .sort_values(sort_columns) .reset_index(drop=True) @@ -167,9 +167,9 @@ def test_compile_results(self): .sort_values(sort_columns) .reset_index(drop=True) ) - if not actual_results.equals(desired_results): + if not actual_results.equals(expected_results): raise ValueError( - f'\n\n\tDesired results:\n{desired_results.to_csv()}' + f'\n\n\tExpected results:\n{expected_results.to_csv()}' f'\n\n\tActual results:\n{actual_results.to_csv()}' )