From 969653b4552db4a9c84038913fbde6a6a84fec15 Mon Sep 17 00:00:00 2001 From: polishchuks Date: Fri, 7 Feb 2025 19:24:03 +0200 Subject: [PATCH 1/2] fix: --- hstest/common/process_utils.py | 8 +- hstest/common/reflection_utils.py | 25 ++- hstest/common/utils.py | 4 +- hstest/dynamic/input/dynamic_input_handler.py | 3 +- hstest/dynamic/input/dynamic_testing.py | 9 +- hstest/dynamic/input/input_mock.py | 4 +- .../dynamic/output/infinite_loop_detector.py | 4 +- hstest/dynamic/output/output_handler.py | 2 - hstest/dynamic/output/output_mock.py | 4 +- hstest/dynamic/security/exit_handler.py | 8 +- hstest/dynamic/system_handler.py | 4 +- hstest/exception/outcomes.py | 4 +- hstest/outcomes/exception_outcome.py | 4 +- hstest/outcomes/outcome.py | 16 +- hstest/outcomes/unexpected_error_outcome.py | 8 +- hstest/stage/django_test.py | 3 +- hstest/stage/flask_test.py | 3 +- hstest/stage/stage_test.py | 13 +- hstest/test_case/test_case.py | 13 +- hstest/testing/execution/process_executor.py | 32 +-- hstest/testing/execution/program_executor.py | 4 +- .../execution/searcher/base_searcher.py | 17 +- .../execution/searcher/cpp_searcher.py | 5 +- .../testing/execution/searcher/go_searcher.py | 8 +- .../execution/searcher/javascript_searcher.py | 4 +- .../execution/searcher/python_searcher.py | 19 +- hstest/testing/execution_options.py | 4 +- hstest/testing/plotting/drawing/drawing.py | 6 +- hstest/testing/plotting/matplotlib_handler.py | 19 +- hstest/testing/plotting/pandas_handler.py | 76 ++++++-- hstest/testing/plotting/seaborn_handler.py | 25 ++- hstest/testing/process_wrapper.py | 14 +- .../runner/async_dynamic_testing_runner.py | 8 +- .../runner/django_application_runner.py | 8 +- hstest/testing/runner/plot_testing_runner.py | 12 +- hstest/testing/state_machine.py | 4 +- hstest/testing/test_run.py | 6 +- setup.py | 4 +- .../test_command_line_args_changed/test.py | 2 +- .../test.py | 4 +- .../test.py | 4 +- .../test.py | 4 +- .../test.py | 4 +- .../test.py | 6 +- .../test.py | 6 +- .../test.py | 6 +- .../test.py | 8 +- .../test.py | 8 +- .../test.py | 10 +- .../test.py | 10 +- .../test.py | 10 +- .../test.py | 2 +- .../test.py | 8 +- .../test.py | 10 +- .../test.py | 16 +- .../main.py | 2 +- .../test.py | 5 +- .../test.py | 8 +- .../test.py | 8 +- .../success_dynamic_input/main.py | 4 +- .../success_dynamic_input/test.py | 39 ++-- .../dynamic_input/test_dynamic_input/main.py | 6 +- .../dynamic_input/test_dynamic_input/test.py | 16 +- .../test.py | 4 +- .../test.py | 4 +- .../test_multiple_dynamic_inputs/test.py | 140 +++++++------ .../test.py | 7 +- .../test.py | 2 +- .../test_dynamic_method_early_exit/test.py | 2 +- .../test_dynamic_method_exception/main.py | 2 +- .../test_dynamic_method_exception/test.py | 2 +- .../test.py | 2 +- .../test.py | 2 +- .../test.py | 7 +- .../test.py | 9 +- .../test.py | 5 +- .../test.py | 6 +- .../test.py | 6 +- .../test.py | 4 +- .../test.py | 4 +- .../dynamic_method/test_files/test.py | 6 +- .../test.py | 12 +- .../test_right_sequence_of_tests/test.py | 2 +- .../test_dynamic_output/main.py | 24 +-- .../test_dynamic_output/test.py | 12 +- .../test_dynamic_output_with_input/main.py | 4 +- .../test_dynamic_output_with_input/test.py | 6 +- .../test_dynamic_output_without_input/main.py | 6 +- .../test_dynamic_output_without_input/test.py | 10 +- .../feedback_on_exception_test_1/main.py | 2 +- .../feedback_on_exception_test_1/test.py | 8 +- .../feedback_on_exception_test_2/test.py | 16 +- .../feedback_on_exception_test_3/test.py | 12 +- .../feedback_on_exception_test_4/test.py | 18 +- .../test.py | 19 +- .../test.py | 19 +- .../dir1/main.py | 2 +- .../test.py | 8 +- .../random_module/main.py | 1 + .../imports/test_import_absolute/test.py | 4 +- .../random_module/main.py | 1 + .../imports/test_import_absolute_2/test.py | 4 +- .../test_import_absolute_error/main.py | 1 + .../test_import_absolute_error/test.py | 2 +- .../test_import_absolute_error_2/main.py | 1 + .../test_import_absolute_error_2/test.py | 2 +- .../main.py | 1 + .../main2.py | 2 +- .../test.py | 4 +- .../main.py | 3 +- .../main2.py | 2 +- .../test.py | 2 +- .../main.py | 2 +- .../main2.py | 2 +- .../test.py | 2 +- .../main.py | 1 + .../main2.py | 2 +- .../test.py | 2 +- .../main.py | 3 +- .../main2.py | 2 +- .../test.py | 2 +- .../main.py | 2 +- .../test.py | 2 +- .../test_import_package/random_module/main.py | 1 + .../imports/test_import_package/test.py | 4 +- .../random_module/main.py | 1 + .../imports/test_import_package_2/test.py | 6 +- .../random_module/main.py | 3 +- .../imports/test_import_package_3/test.py | 4 +- .../random_module/main.py | 3 +- .../imports/test_import_package_4/test.py | 6 +- .../random_module/main.py | 3 +- .../imports/test_import_package_5/test.py | 4 +- .../random_module/main.py | 3 +- .../imports/test_import_package_6/test.py | 4 +- .../random_module/main.py | 3 +- .../imports/test_import_package_7/test.py | 6 +- .../imports/test_import_relative/main.py | 1 + .../imports/test_import_relative/test.py | 4 +- .../test_import_relative_error/main.py | 1 + .../test_import_relative_error/test.py | 4 +- .../test_import_relative_error_2/main.py | 2 +- .../test_import_relative_error_2/test.py | 4 +- .../main.py | 1 + .../main2.py | 1 + .../test.py | 4 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 2 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 4 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 4 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 2 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 6 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 6 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 6 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 6 +- .../main1.py | 2 +- .../main2.py | 2 +- .../test.py | 8 +- .../imports/user_main_file_not_exists/test.py | 2 +- .../test.py | 4 +- .../imports/user_module_not_exists/test.py | 4 +- .../random_module/main.py | 2 +- .../test.py | 4 +- .../infinite_loop_test_char/test.py | 2 +- .../infinite_loop_test_input_request/main.py | 1 - .../infinite_loop_test_input_request/test.py | 2 +- .../infinite_loop_test_line_1/test.py | 2 +- .../infinite_loop_test_line_10/test.py | 2 +- .../infinite_loop_test_line_11/test.py | 2 +- .../infinite_loop_test_line_2/test.py | 2 +- .../infinite_loop_test_line_3/test.py | 2 +- .../infinite_loop_test_line_4/test.py | 2 +- .../infinite_loop_test_line_5/test.py | 2 +- .../infinite_loop_test_line_6/test.py | 2 +- .../infinite_loop_test_line_7/test.py | 2 +- .../infinite_loop_test_line_8/test.py | 2 +- .../infinite_loop_test_line_9/test.py | 2 +- .../infinite_loop_test_not_working/test.py | 2 +- .../exception_while_reading/test.py | 21 +- .../exception_while_reading_2/test.py | 6 +- .../success_but_not_used_input_1/test.py | 6 +- .../success_but_not_used_input_2/main.py | 2 +- .../success_but_not_used_input_2/test.py | 8 +- .../main.py | 8 +- .../test.py | 4 +- .../input_handle/test_out_of_input_1/test.py | 14 +- .../input_handle/test_out_of_input_2/test.py | 7 +- .../input_handle/test_out_of_input_3/test.py | 6 +- .../input_handle/test_out_of_input_4/test.py | 5 +- .../lib/exception_in_user_code/test.py | 14 +- .../lib/exception_in_user_code_2/test.py | 6 +- .../exception_in_user_code_3/module/main.py | 7 +- .../lib/order/test_order_complex/test.py | 16 +- tests/outcomes/lib/success/test.py | 6 +- tests/outcomes/lib/success2/test.py | 8 +- .../lib/test_case_same_objects/main.py | 2 +- .../lib/test_case_same_objects/test.py | 2 +- .../outcomes/lib/test_copy_to_attach/main.py | 2 +- .../outcomes/lib/test_copy_to_attach/test.py | 6 +- .../outcomes/lib/test_curr_test_case/test.py | 16 +- tests/outcomes/lib/test_curr_test_num/test.py | 8 +- .../outcomes/lib/test_custom_checker/main.py | 2 +- .../outcomes/lib/test_custom_checker/test.py | 8 +- .../lib/test_custom_checker_fail/main.py | 2 +- .../lib/test_custom_checker_fail/test.py | 19 +- .../outcomes/lib/test_nbsp_in_output/main.py | 2 +- .../outcomes/lib/test_nbsp_in_output/test.py | 6 +- .../lib/test_run_test_inside_test/test.py | 2 +- .../long_output_on_raise_wrong_answer/test.py | 8 +- .../long_output_on_unexpected_error/test.py | 8 +- .../long_output_with_arguments/test.py | 4 +- .../test_label_on_long_output/test.py | 10 +- .../test.py | 8 +- .../wrong_output_with_too_long_output/test.py | 8 +- .../main.py | 4 +- .../test.py | 38 ++-- .../main.py | 4 +- .../test.py | 12 +- .../main.py | 4 +- .../test.py | 12 +- .../correct/test_parametrized_data/test.py | 10 +- .../correct/test_parametrized_data_2/test.py | 2 +- .../correct/test_parametrized_data_3/test.py | 6 +- .../correct/test_parametrized_data_4/test.py | 10 +- .../correct/test_parametrized_data_5/test.py | 10 +- .../wrong/test_wrong_data/test.py | 10 +- .../wrong/test_wrong_data_2/test.py | 6 +- tests/outcomes/plot/area/pandas/main.py | 18 +- tests/outcomes/plot/area/test_area_drawing.py | 12 +- tests/outcomes/plot/bar/matplotlib/main.py | 2 - tests/outcomes/plot/bar/matplotlib/test.py | 4 +- .../plot/bar/pandas/test_example/cleaning.py | 18 +- .../plot/bar/pandas/test_example/test.py | 2 +- .../pandas_dataframe_plot_no_x_no_y.py | 4 +- tests/outcomes/plot/bar/seaborn/main.py | 13 +- tests/outcomes/plot/bar/seaborn/test.py | 17 +- tests/outcomes/plot/bar/test_bar_drawing.py | 16 +- .../data_no_x/pandas_column_plot.py | 9 +- .../data_no_x/pandas_column_plot_kind.py | 11 +- .../data_no_x/pandas_column_string_plot.py | 11 +- .../pandas_column_string_plot_kind.py | 11 +- .../data_no_x/pandas_dataframe_plot.py | 7 +- .../data_no_x/pandas_dataframe_plot_kind.py | 9 +- .../data_no_x/pandas_dataframe_plot_kind_y.py | 12 +- .../data_no_x/pandas_dataframe_plot_y.py | 12 +- .../data_no_x/pandas_series_plot.py | 4 +- .../data_no_x/pandas_series_plot_kind.py | 6 +- .../bar/universal_tests/data_no_x/test.py | 10 +- .../matplotlib_data_dataframe_ax.py | 11 +- .../matplotlib_data_dataframe_plt.py | 11 +- .../data_simple/matplotlib_x_array_ax.py | 3 +- .../data_simple/matplotlib_x_array_plt.py | 3 +- .../data_simple/matplotlib_x_column_ax.py | 9 +- .../data_simple/matplotlib_x_column_plt.py | 9 +- .../matplotlib_x_column_string_ax.py | 11 +- .../matplotlib_x_column_string_plt.py | 11 +- .../data_simple/matplotlib_x_dataframe_ax.py | 7 +- .../data_simple/matplotlib_x_dataframe_plt.py | 9 +- .../data_simple/matplotlib_x_list_ax.py | 2 - .../data_simple/matplotlib_x_list_plt.py | 2 - .../data_simple/matplotlib_x_series_ax.py | 4 +- .../data_simple/matplotlib_x_series_plt.py | 4 +- .../data_simple/matplotlib_x_tuple_ax.py | 2 - .../data_simple/matplotlib_x_tuple_plt.py | 2 - .../pandas_dataframe_plot_kind_x.py | 11 +- .../pandas_dataframe_plot_kind_xy.py | 12 +- .../data_simple/pandas_dataframe_plot_x.py | 11 +- .../data_simple/pandas_dataframe_plot_xy.py | 12 +- .../data_simple/pandas_series_plot_kind.py | 6 +- .../bar/universal_tests/data_simple/test.py | 10 +- .../pandas_dataframe_plot_kind_x.py | 12 +- .../pandas_dataframe_plot_kind_xy.py | 14 +- .../data_two_pics/pandas_dataframe_plot_x.py | 12 +- .../data_two_pics/pandas_dataframe_plot_xy.py | 14 +- .../bar/universal_tests/data_two_pics/test.py | 8 +- .../pandas_dataframe_plot.py | 9 +- .../pandas_dataframe_plot_kind.py | 11 +- .../pandas_dataframe_plot_kind_y.py | 12 +- .../pandas_dataframe_plot_y.py | 12 +- .../data_two_pics_no_x/test.py | 8 +- .../plot/box/matplotlib/test_data/main.py | 2 - .../plot/box/matplotlib/test_data_2/main.py | 50 ++++- .../plot/box/matplotlib/test_data_2/test.py | 6 +- tests/outcomes/plot/box/pandas/main.py | 13 +- tests/outcomes/plot/box/seaborn/main.py | 2 - tests/outcomes/plot/box/test_box_drawing.py | 12 +- tests/outcomes/plot/cat/seaborn/main.py | 2 - tests/outcomes/plot/cat/test_cat_drawing.py | 12 +- tests/outcomes/plot/dis/pandas/main.py | 6 +- tests/outcomes/plot/dis/seaborn/main.py | 2 - tests/outcomes/plot/dis/test_dis_drawing.py | 12 +- .../outcomes/plot/heatmap/matplotlib/main.py | 21 +- .../outcomes/plot/heatmap/matplotlib/test.py | 3 +- tests/outcomes/plot/heatmap/seaborn/main.py | 21 +- tests/outcomes/plot/heatmap/seaborn/test.py | 3 +- .../plot/heatmap/test_heatmap_drawing.py | 12 +- tests/outcomes/plot/hexbin/pandas/main.py | 8 +- .../plot/hexbin/test_hexbin_drawing.py | 12 +- .../plot/hist/matplotlib/test_data/main.py | 8 +- .../plot/hist/matplotlib/test_data/test.py | 12 +- .../hist/matplotlib/test_sorting_data/main.py | 10 +- .../hist/matplotlib/test_sorting_data/test.py | 12 +- .../todo/x_data_with_weights_plt/main.py | 12 +- .../todo/x_data_with_weights_plt/test.py | 8 +- .../matplotlib/todo/x_dataframe_plt/main.py | 10 +- .../matplotlib/todo/x_dataframe_plt/test.py | 9 +- .../plot/hist/pandas/test_data/main.py | 15 +- .../plot/hist/pandas/test_data/test.py | 6 +- .../plot/hist/pandas/test_group_by/main.py | 11 +- .../hist/pandas/test_sorting_data/main.py | 6 +- .../hist/pandas/test_sorting_data/test.py | 11 +- .../plot/hist/seaborn/test_data/main.py | 14 +- .../plot/hist/seaborn/test_data/test.py | 4 +- .../hist/seaborn/test_sorting_data/main.py | 14 +- .../hist/seaborn/test_sorting_data/test.py | 4 +- tests/outcomes/plot/hist/test_hist_drawing.py | 14 +- .../matplotlib_data_dataframe_ax.py | 11 +- .../matplotlib_data_dataframe_plt.py | 11 +- .../data_simple/matplotlib_x_array_ax.py | 3 +- .../data_simple/matplotlib_x_array_plt.py | 3 +- .../data_simple/matplotlib_x_column_ax.py | 9 +- .../data_simple/matplotlib_x_column_plt.py | 9 +- .../matplotlib_x_column_string_ax.py | 11 +- .../matplotlib_x_column_string_plt.py | 11 +- .../data_simple/matplotlib_x_dataframe_ax.py | 7 +- .../data_simple/matplotlib_x_dataframe_plt.py | 7 +- .../data_simple/matplotlib_x_list_ax.py | 2 - .../data_simple/matplotlib_x_list_plt.py | 2 - .../data_simple/matplotlib_x_series_ax.py | 4 +- .../data_simple/matplotlib_x_series_plt.py | 4 +- .../data_simple/matplotlib_x_tuple_ax.py | 2 - .../data_simple/matplotlib_x_tuple_plt.py | 2 - .../data_simple/pandas_column.py | 9 +- .../data_simple/pandas_column_plot.py | 9 +- .../data_simple/pandas_column_plot_kind.py | 11 +- .../data_simple/pandas_column_string.py | 11 +- .../data_simple/pandas_column_string_plot.py | 11 +- .../pandas_column_string_plot_kind.py | 11 +- .../data_simple/pandas_dataframe.py | 7 +- .../data_simple/pandas_dataframe_column.py | 11 +- .../data_simple/pandas_dataframe_plot.py | 7 +- .../pandas_dataframe_plot_column.py | 11 +- .../data_simple/pandas_dataframe_plot_kind.py | 9 +- .../pandas_dataframe_plot_kind_column.py | 11 +- .../pandas_dataframe_plot_kind_x.py | 11 +- .../pandas_dataframe_plot_kind_xy.py | 11 +- .../pandas_dataframe_plot_kind_y.py | 11 +- .../data_simple/pandas_dataframe_plot_x.py | 11 +- .../data_simple/pandas_dataframe_plot_xy.py | 11 +- .../data_simple/pandas_dataframe_plot_y.py | 11 +- .../data_simple/pandas_series.py | 4 +- .../data_simple/pandas_series_plot.py | 4 +- .../data_simple/pandas_series_plot_kind.py | 6 +- .../data_simple/seaborn_array.py | 3 +- .../data_simple/seaborn_column.py | 9 +- .../data_simple/seaborn_column_string.py | 11 +- .../data_simple/seaborn_dataframe.py | 6 +- .../data_simple/seaborn_dataframe_x.py | 11 +- .../data_simple/seaborn_dataframe_xy.py | 11 +- .../data_simple/seaborn_dataframe_y.py | 11 +- .../data_simple/seaborn_list.py | 2 - .../data_simple/seaborn_series.py | 4 +- .../data_simple/seaborn_tuple.py | 2 - .../hist/universal_tests/data_simple/test.py | 10 +- .../data_two_pics/matplotlib_x_arrays_ax.py | 3 +- .../data_two_pics/matplotlib_x_arrays_plt.py | 3 +- .../data_two_pics/matplotlib_x_columns_ax.py | 9 +- .../data_two_pics/matplotlib_x_columns_plt.py | 9 +- .../data_two_pics/matplotlib_x_lists_ax.py | 2 - .../data_two_pics/matplotlib_x_lists_plt.py | 2 - .../data_two_pics/matplotlib_x_tuples_ax.py | 2 - .../data_two_pics/matplotlib_x_tuples_plt.py | 2 - .../data_two_pics/pandas_column_hist_by.py | 26 ++- .../pandas_column_string_hist_by.py | 26 ++- .../data_two_pics/pandas_dataframe_hist.py | 9 +- .../pandas_dataframe_hist_by_dataframe.py | 26 ++- .../pandas_dataframe_hist_by_str.py | 26 ++- .../pandas_dataframe_plot_hist.py | 9 +- .../pandas_dataframe_plot_hist_by.py | 26 ++- .../pandas_dataframe_plot_kind_hist.py | 11 +- .../pandas_dataframe_plot_kind_hist_by.py | 26 ++- .../data_two_pics/pandas_series_hist_by.py | 4 +- .../data_two_pics/seaborn_histplot_array.py | 3 +- .../seaborn_histplot_dataframe.py | 9 +- .../seaborn_histplot_dataframe_hue.py | 26 ++- .../data_two_pics/seaborn_histplot_list.py | 2 - .../data_two_pics/seaborn_histplot_tuple.py | 2 - .../universal_tests/data_two_pics/test.py | 8 +- tests/outcomes/plot/line/matplotlib/main.py | 2 - tests/outcomes/plot/line/matplotlib/test.py | 6 +- tests/outcomes/plot/line/pandas/main.py | 10 +- tests/outcomes/plot/line/pandas/test.py | 6 +- tests/outcomes/plot/line/seaborn/main.py | 6 +- tests/outcomes/plot/line/seaborn/test.py | 6 +- tests/outcomes/plot/line/test_line_drawing.py | 14 +- tests/outcomes/plot/lm/seaborn/main.py | 2 - tests/outcomes/plot/lm/test_lm_drawing.py | 10 +- tests/outcomes/plot/pie/test_pie_drawing.py | 16 +- .../data_no_label/matplotlib_y_array_ax.py | 2 - .../data_no_label/matplotlib_y_array_plt.py | 2 - .../data_no_label/matplotlib_y_nparray_ax.py | 3 +- .../data_no_label/matplotlib_y_nparray_plt.py | 3 +- .../data_no_label/matplotlib_y_tuple_ax.py | 2 - .../data_no_label/matplotlib_y_tuple_plt.py | 2 - .../pie/universal_tests/data_no_label/test.py | 12 +- .../data_simple/matplotlib_y_array_ax.py | 4 +- .../data_simple/matplotlib_y_array_plt.py | 4 +- .../data_simple/matplotlib_y_nparray_ax.py | 5 +- .../data_simple/matplotlib_y_nparray_plt.py | 5 +- .../data_simple/matplotlib_y_tuple_ax.py | 4 +- .../data_simple/matplotlib_y_tuple_plt.py | 4 +- .../pandas_dataframe_plot_kind_y.py | 13 +- .../data_simple/pandas_dataframe_plot_y.py | 13 +- .../data_simple/pandas_series_plot_kind_y.py | 8 +- .../data_simple/pandas_series_plot_y.py | 6 +- .../pie/universal_tests/data_simple/test.py | 10 +- .../data_two_pics/pandas_dataframe_plot.py | 11 +- .../pandas_dataframe_plot_kind.py | 13 +- .../pie/universal_tests/data_two_pics/test.py | 14 +- .../outcomes/plot/scatter/matplotlib/main.py | 2 - .../outcomes/plot/scatter/matplotlib/test.py | 12 +- tests/outcomes/plot/scatter/pandas/main.py | 14 +- tests/outcomes/plot/scatter/pandas/test.py | 12 +- tests/outcomes/plot/scatter/seaborn/main.py | 12 +- tests/outcomes/plot/scatter/seaborn/test.py | 9 +- .../plot/scatter/test_scatter_drawing.py | 14 +- .../plot/test_matplotlib/test_revert/main.py | 22 ++- .../plot/test_matplotlib/test_revert/test.py | 6 +- .../plot/test_pandas/test_revert/main.py | 88 ++++----- .../plot/test_pandas/test_revert/test.py | 6 +- .../plot/test_seaborn/test_revert/main.py | 33 ++-- .../plot/test_seaborn/test_revert/test.py | 6 +- tests/outcomes/plot/universal_test.py | 12 +- .../plot/violinplot/matplotlib/main.py | 3 - .../plot/violinplot/matplotlib/test.py | 3 +- .../outcomes/plot/violinplot/seaborn/main.py | 2 - .../outcomes/plot/violinplot/seaborn/test.py | 3 +- .../plot/violinplot/test_violin_drawing.py | 12 +- .../outcomes/repeating/test_repeating/test.py | 2 +- .../repeating/test_repeating_2/test.py | 2 +- .../repeating/test_repeating_3/test.py | 2 +- .../test.py | 6 +- .../test_repeating_wrong_amount/test.py | 2 +- tests/outcomes/runtime_exit/test_quit/test.py | 6 +- .../test.py | 8 +- .../test.py | 11 +- .../test.py | 11 +- .../search/go_files/go_files1/tests.py | 2 +- .../search/go_files/go_files2/tests.py | 5 +- .../search/go_files/go_files3/tests.py | 2 +- .../dir/main.py | 2 +- .../dir/main2.py | 2 +- .../test.py | 7 +- .../dir/main.py | 1 + .../dir/main2.py | 3 +- .../test.py | 7 +- .../dir/main.py | 1 + .../dir/main2.py | 2 +- .../test.py | 7 +- .../dir/main.py | 3 +- .../dir/main2.py | 2 +- .../test.py | 5 +- .../dir/main.py | 1 - .../dir/main2.py | 2 +- .../test.py | 5 +- .../dir/main.py | 1 - .../dir/main2.py | 2 +- .../test.py | 5 +- .../dir/main.py | 1 - .../dir/main2.py | 2 +- .../dir/main3.py | 2 +- .../test.py | 6 +- .../simple_test/test_simple_test_case/test.py | 4 +- .../test_simple_test_case_fail/test.py | 16 +- .../stderr/disable_catching_stderr/main.py | 2 +- .../stderr/disable_catching_stderr/test.py | 11 +- .../main.py | 2 +- .../test.py | 11 +- .../test.py | 6 +- .../test.py | 6 +- .../test.py | 11 +- .../test.py | 6 +- .../test.py | 6 +- .../test.py | 6 +- .../test.py | 11 +- .../test.py | 6 +- .../syntax_error/test_empty_eval/test.py | 6 +- .../test_error_using_eval/test.py | 6 +- .../test_error_using_eval_and_print/test.py | 6 +- .../test_error_using_exec/test.py | 6 +- .../syntax_error/test_syntax_error_1/test.py | 4 +- .../syntax_error/test_syntax_error_2/test.py | 6 +- .../test_passed_thrown_in_check_1/test.py | 5 +- .../test_passed_thrown_in_check_2/test.py | 5 +- .../main.py | 2 +- .../test.py | 13 +- .../main.py | 2 +- .../test.py | 13 +- .../timeout/test_default_time_limit/main.py | 1 + .../timeout/test_default_time_limit/test.py | 8 +- .../timeout/test_no_time_limit/main.py | 1 + .../timeout/test_no_time_limit/test.py | 2 +- tests/outcomes/timeout/test_timeout_1/main.py | 1 + tests/outcomes/timeout/test_timeout_1/test.py | 6 +- tests/outcomes/timeout/test_timeout_2/main.py | 1 + tests/outcomes/timeout/test_timeout_2/test.py | 8 +- tests/outcomes/timeout/test_timeout_3/test.py | 8 +- .../unexpected_error_add_input_1/test.py | 8 +- .../unexpected_error_add_input_2/test.py | 8 +- .../unexpected_error_add_input_3/test.py | 10 +- .../unexpected_error_during_checking/main.py | 2 +- .../unexpected_error_during_checking/test.py | 2 +- .../main.py | 2 +- .../test.py | 4 +- .../unexpected_error_empty_test_cases/main.py | 2 +- .../unexpected_error_empty_test_cases/test.py | 4 +- .../unexpected_error_generating_tests/main.py | 2 +- .../unexpected_error_generating_tests/test.py | 6 +- .../main.py | 2 +- .../test.py | 2 +- .../unexpected_error_no_check_method/main.py | 2 +- .../unexpected_error_no_check_method/test.py | 6 +- .../main.py | 2 +- .../test.py | 4 +- .../wrong_answer_dynamic_input_1/main.py | 2 +- .../wrong_answer_dynamic_input_1/test.py | 2 +- .../wrong_answer_dynamic_input_2/main.py | 2 +- .../wrong_answer_dynamic_input_2/test.py | 17 +- .../wrong_answer_dynamic_input_3/test.py | 46 +++-- .../wrong_answer_dynamic_input_4/test.py | 44 +++-- .../wrong_answer_in_test_1/test.py | 6 +- .../wrong_answer_in_test_2/test.py | 7 +- .../wrong_answer_thrown_in_check_1/test.py | 7 +- .../wrong_answer_thrown_in_check_2/test.py | 7 +- .../main.py | 2 +- .../test.py | 13 +- .../main.py | 2 +- .../test.py | 13 +- .../go/coffee_machine/stage1/tests.py | 6 +- .../go/coffee_machine/stage1_ce/tests.py | 14 +- .../go/coffee_machine/stage1_ex/tests.py | 12 +- .../go/coffee_machine/stage1_wa/tests.py | 12 +- .../go/coffee_machine/stage2/tests.py | 41 ++-- .../go/coffee_machine/stage3/tests.py | 101 +++++----- .../go/coffee_machine/stage4/tests.py | 184 +++++++++--------- .../go/coffee_machine/stage5/tests.py | 137 ++++++------- .../javascript/coffee_machine/stage1/tests.py | 9 +- .../coffee_machine/stage1_ce/tests.py | 15 +- .../coffee_machine/stage1_ex/tests.py | 20 +- .../coffee_machine/stage1_wa/tests.py | 12 +- .../javascript/coffee_machine/stage2/tests.py | 41 ++-- .../javascript/coffee_machine/stage3/tests.py | 101 +++++----- .../javascript/coffee_machine/stage4/tests.py | 184 +++++++++--------- .../javascript/coffee_machine/stage5/tests.py | 137 ++++++------- .../simple_chatty_bot/stage1/tests.py | 15 +- .../simple_chatty_bot/stage2/tests.py | 24 ++- .../simple_chatty_bot/stage3/tests.py | 35 ++-- .../simple_chatty_bot/stage4/tests.py | 52 ++--- .../simple_chatty_bot/stage5/tests.py | 60 +++--- .../javascript/zookeeper/stage1/tests.py | 19 +- .../javascript/zookeeper/stage2/tests.py | 2 +- .../javascript/zookeeper/stage3/tests.py | 25 ++- .../javascript/zookeeper/stage4/tests.py | 40 ++-- .../stage1/machine/coffee_machine.py | 6 +- .../python/coffee_machine/stage1/tests.py | 9 +- .../python/coffee_machine/stage2/tests.py | 41 ++-- .../stage3/machine/coffee_machine.py | 34 ++-- .../python/coffee_machine/stage3/tests.py | 101 +++++----- .../stage4/machine/coffee_machine.py | 20 +- .../python/coffee_machine/stage4/tests.py | 184 +++++++++--------- .../stage5/machine/coffee_machine.py | 10 +- .../python/coffee_machine/stage5/tests.py | 137 ++++++------- .../shell/coffee_machine/stage1/tests.py | 14 +- .../shell/coffee_machine/stage1_ex/tests.py | 14 +- .../shell/coffee_machine/stage1_wa/tests.py | 14 +- .../shell/coffee_machine/stage2/tests.py | 43 ++-- tests/sql/test_db_connection/sqlite/test.py | 4 +- .../test_parsing_sql_files/parsing1/test.py | 23 ++- .../test.py | 19 +- .../test_execute_with_plain_query/test.py | 18 +- .../test_execute_with_query_name/test.py | 14 +- .../test.py | 20 +- .../test_queries/sqlite/create_table/test.py | 14 +- .../sqlite/insert_and_select_data/test.py | 21 +- .../sqlite/test_parsing_empty_query/test.py | 26 +-- tests/test_testcase.py | 8 +- tests/testing.py | 17 +- 602 files changed, 3268 insertions(+), 3077 deletions(-) diff --git a/hstest/common/process_utils.py b/hstest/common/process_utils.py index 0c29949f..9863a095 100644 --- a/hstest/common/process_utils.py +++ b/hstest/common/process_utils.py @@ -11,7 +11,9 @@ class DaemonThreadPoolExecutor(ThreadPoolExecutor): - def __init__(self, max_workers: int = 1, name: str = "", group: ThreadGroup = None) -> None: + def __init__( + self, max_workers: int = 1, name: str = "", group: ThreadGroup = None + ) -> None: super().__init__(max_workers=max_workers, thread_name_prefix=name) self.group = group @@ -36,7 +38,9 @@ def weakref_cb(_, q=self._work_queue) -> None: self._initargs, ) - t = threading.Thread(name=thread_name, target=_worker, args=args, group=self.group) + t = threading.Thread( + name=thread_name, target=_worker, args=args, group=self.group + ) t.daemon = True t.start() self._threads.add(t) diff --git a/hstest/common/reflection_utils.py b/hstest/common/reflection_utils.py index 9816ebc6..05d9f0f9 100644 --- a/hstest/common/reflection_utils.py +++ b/hstest/common/reflection_utils.py @@ -13,8 +13,14 @@ def is_tests(stage): return ( (package and package.startswith("tests.outcomes.")) or (package and package.startswith("tests.projects.")) - or (file and f"{os.sep}hs-test-python{os.sep}tests{os.sep}outcomes{os.sep}" in file) - or (file and f"{os.sep}hs-test-python{os.sep}tests{os.sep}projects{os.sep}" in file) + or ( + file + and f"{os.sep}hs-test-python{os.sep}tests{os.sep}outcomes{os.sep}" in file + ) + or ( + file + and f"{os.sep}hs-test-python{os.sep}tests{os.sep}projects{os.sep}" in file + ) or (file and f"{os.sep}hs-test-python{os.sep}tests{os.sep}sql{os.sep}" in file) ) @@ -49,7 +55,9 @@ def get_stacktrace(ex: BaseException, hide_internals=False) -> str: break user_traceback += [tr] - user_traceback = [tr for tr in user_traceback if f"{os.sep}hstest{os.sep}" not in tr] + user_traceback = [ + tr for tr in user_traceback if f"{os.sep}hstest{os.sep}" not in tr + ] return clean_stacktrace(traceback_stack, user_traceback[::-1], user_dir) @@ -59,7 +67,8 @@ def _fix_python_syntax_error(str_trace: str) -> str: python_traceback_start = ' File "' is_python_syntax_error = "SyntaxError" in str_trace and ( - f"\n{python_traceback_start}" in str_trace or str_trace.startswith(python_traceback_start) + f"\n{python_traceback_start}" in str_trace + or str_trace.startswith(python_traceback_start) ) if is_python_syntax_error and python_traceback_initial_phrase not in str_trace: @@ -104,10 +113,10 @@ def str_to_stacktrace(str_trace: str) -> str: File "C:\Users\**\JetBrains\**\plugins\python\helpers\pydev\pydevd.py", line 1477, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Users\**\JetBrains\**\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile - exec(compile(contents+"\n", file, 'exec'), glob, loc) + exec(compile(contents+"\n", file, 'exec'), glob, loc) Which will appear when testing locally inside PyCharm. - """ # noqa: W291, E501 + """ # noqa: E501 if f"{os.sep}JetBrains{os.sep}" in trace: continue @@ -166,7 +175,9 @@ def clean_stacktrace( if trace.startswith(" " * 4): # Trace line that starts with 4 is a line with SyntaxError cleaned_traceback += [trace] - elif user_dir in trace or ("<" in trace and ">" in trace and "" in trace and " lines that are always in the stacktrace # but include , because it's definitely user's code if not user_dir.startswith("<"): diff --git a/hstest/common/utils.py b/hstest/common/utils.py index 49acea4d..123df9b0 100644 --- a/hstest/common/utils.py +++ b/hstest/common/utils.py @@ -31,7 +31,9 @@ def clean_text(text: str) -> str: return text.replace("\r\n", "\n").replace("\r", "\n").replace("\u00a0", "\u0020") -def try_many_times(times_to_try: int, sleep_time_ms: int, exit_func: Callable[[], bool]) -> bool: +def try_many_times( + times_to_try: int, sleep_time_ms: int, exit_func: Callable[[], bool] +) -> bool: while times_to_try > 0: times_to_try -= 1 if exit_func(): diff --git a/hstest/dynamic/input/dynamic_input_handler.py b/hstest/dynamic/input/dynamic_input_handler.py index 5226a317..f2b7b790 100644 --- a/hstest/dynamic/input/dynamic_input_handler.py +++ b/hstest/dynamic/input/dynamic_input_handler.py @@ -34,7 +34,6 @@ def _eject_next_input(self) -> None: new_input = clean_text(new_input) - if new_input.endswith("\n"): - new_input = new_input[:-1] + new_input = new_input.removesuffix("\n") self._input_lines += new_input.split("\n") diff --git a/hstest/dynamic/input/dynamic_testing.py b/hstest/dynamic/input/dynamic_testing.py index 774b0c59..4762e3a9 100644 --- a/hstest/dynamic/input/dynamic_testing.py +++ b/hstest/dynamic/input/dynamic_testing.py @@ -45,7 +45,10 @@ def extract_parametrized_data(self) -> None: self.data = [[]] if type(self.data) not in {list, tuple}: - msg = f"{self.name} should be of type " f'"list" or "tuple", found {type(self.data)}.' + msg = ( + f"{self.name} should be of type " + f'"list" or "tuple", found {type(self.data)}.' + ) raise UnexpectedError(msg) if len(self.data) == 0: @@ -111,7 +114,9 @@ class InputFunctionHandler: def __init__(self, funcs: list[DynamicInputFunction]) -> None: self.input_funcs: list[DynamicInputFunction] = [] for func in funcs: - self.input_funcs += [DynamicInputFunction(func.trigger_count, func.input_function)] + self.input_funcs += [ + DynamicInputFunction(func.trigger_count, func.input_function) + ] def eject_next_input(self, curr_output: str) -> str | None: if len(self.input_funcs) == 0: diff --git a/hstest/dynamic/input/input_mock.py b/hstest/dynamic/input/input_mock.py index 3447c7f2..7d64183b 100644 --- a/hstest/dynamic/input/input_mock.py +++ b/hstest/dynamic/input/input_mock.py @@ -32,7 +32,9 @@ def install_input_handler( if obj in self.handlers: msg = "Cannot install input handler from the same program twice" raise UnexpectedError(msg) - self.handlers[obj] = ConditionalInputHandler(condition, DynamicInputHandler(input_func)) + self.handlers[obj] = ConditionalInputHandler( + condition, DynamicInputHandler(input_func) + ) def uninstall_input_handler(self, obj: Any) -> None: if obj not in self.handlers: diff --git a/hstest/dynamic/output/infinite_loop_detector.py b/hstest/dynamic/output/infinite_loop_detector.py index 305f97c0..011faaae 100644 --- a/hstest/dynamic/output/infinite_loop_detector.py +++ b/hstest/dynamic/output/infinite_loop_detector.py @@ -132,7 +132,9 @@ def _check_repetition_size(self, lines_repeated: int) -> None: return if lines_repeated == 1: - self._fail(f"Last {lines_to_check} lines your program printed are the same.") + self._fail( + f"Last {lines_to_check} lines your program printed are the same." + ) else: self._fail( f"Last {lines_to_check} lines your program printed have " diff --git a/hstest/dynamic/output/output_handler.py b/hstest/dynamic/output/output_handler.py index 98004fcc..04060369 100644 --- a/hstest/dynamic/output/output_handler.py +++ b/hstest/dynamic/output/output_handler.py @@ -40,8 +40,6 @@ def print(obj) -> None: if group: OutputHandler.get_real_out().write(full) OutputHandler.get_real_out().flush() - else: - pass @staticmethod def get_real_out() -> io.TextIOWrapper: diff --git a/hstest/dynamic/output/output_mock.py b/hstest/dynamic/output/output_mock.py index 38303c9a..782ffc16 100644 --- a/hstest/dynamic/output/output_mock.py +++ b/hstest/dynamic/output/output_mock.py @@ -52,7 +52,9 @@ def close(self) -> None: self._original: RealOutputMock = RealOutputMock(real_out) self._cloned: list[str] = [] # used in check function self._dynamic: list[str] = [] # used to append inputs - self._partial: dict[Any, ConditionalOutput] = {} # separated outputs for each program + self._partial: dict[Any, ConditionalOutput] = ( + {} + ) # separated outputs for each program self._is_stderr = is_stderr @property diff --git a/hstest/dynamic/security/exit_handler.py b/hstest/dynamic/security/exit_handler.py index c48f82e9..a83cbd69 100644 --- a/hstest/dynamic/security/exit_handler.py +++ b/hstest/dynamic/security/exit_handler.py @@ -33,8 +33,12 @@ def is_replaced(): def replace_exit() -> None: if not ExitHandler._saved: ExitHandler._saved = True - ExitHandler._builtins_quit = builtins.quit if hasattr(builtins, "quit") else None - ExitHandler._builtins_exit = builtins.exit if hasattr(builtins, "exit") else None + ExitHandler._builtins_quit = ( + builtins.quit if hasattr(builtins, "quit") else None + ) + ExitHandler._builtins_exit = ( + builtins.exit if hasattr(builtins, "exit") else None + ) ExitHandler._os_kill = os.kill if hasattr(os, "kill") else None ExitHandler._os__exit = os._exit if hasattr(os, "_exit") else None ExitHandler._os_killpg = os.killpg if hasattr(os, "killpg") else None diff --git a/hstest/dynamic/system_handler.py b/hstest/dynamic/system_handler.py index 09f50cc6..988d30e2 100644 --- a/hstest/dynamic/system_handler.py +++ b/hstest/dynamic/system_handler.py @@ -60,7 +60,9 @@ def _unlock_system_for_testing() -> None: SystemHandler.__locker_thread = None @staticmethod - def install_handler(obj: Any, condition: Condition, input_func: DynamicTestFunction) -> None: + def install_handler( + obj: Any, condition: Condition, input_func: DynamicTestFunction + ) -> None: InputHandler.install_input_handler(obj, condition, input_func) OutputHandler.install_output_handler(obj, condition) diff --git a/hstest/exception/outcomes.py b/hstest/exception/outcomes.py index 7000582d..20cb2a47 100644 --- a/hstest/exception/outcomes.py +++ b/hstest/exception/outcomes.py @@ -24,7 +24,9 @@ def __init__(self, error_text: str) -> None: class OutOfInputError(ErrorWithFeedback): def __init__(self) -> None: - super().__init__("Program ran out of input. You tried to read more than expected.") + super().__init__( + "Program ran out of input. You tried to read more than expected." + ) class UnexpectedError(OutcomeError): diff --git a/hstest/outcomes/exception_outcome.py b/hstest/outcomes/exception_outcome.py index 2216402e..3cf67223 100644 --- a/hstest/outcomes/exception_outcome.py +++ b/hstest/outcomes/exception_outcome.py @@ -26,7 +26,9 @@ def __init__(self, test_num: int, ex: ExceptionWithFeedback) -> None: self.error_text = "" eof = "EOFError: EOF when reading a line" - eof_feedback = "Probably your program run out of input (tried to read more than expected)" + eof_feedback = ( + "Probably your program run out of input (tried to read more than expected)" + ) if self.stack_trace.strip().endswith(eof): self.error_text += "\n\n" + eof_feedback diff --git a/hstest/outcomes/outcome.py b/hstest/outcomes/outcome.py index 15ca9a37..b0103bdd 100644 --- a/hstest/outcomes/outcome.py +++ b/hstest/outcomes/outcome.py @@ -13,7 +13,9 @@ class Outcome: - def __init__(self, test_number: int = 0, error_text: str = "", stack_trace: str = "") -> None: + def __init__( + self, test_number: int = 0, error_text: str = "", stack_trace: str = "" + ) -> None: self.test_number: int = test_number self.error_text: str = error_text self.stack_trace: str = stack_trace @@ -44,8 +46,12 @@ def __str__(self) -> str: trimmed_out = self.__trim_lines(full_out) trimmed_err = self.__trim_lines(full_err) - worth_showing_err = len(full_err.strip()) != 0 and full_err.strip() not in result - worth_showing_out = len(full_out.strip()) != 0 and full_out.strip() not in result + worth_showing_err = ( + len(full_err.strip()) != 0 and full_err.strip() not in result + ) + worth_showing_out = ( + len(full_out.strip()) != 0 and full_out.strip() not in result + ) worth_showing_args = len(arguments.strip()) != 0 from hstest.stage_test import StageTest @@ -57,9 +63,7 @@ def __str__(self) -> str: if worth_showing_out or worth_showing_err: result += "Please find below the output of your program during this failed test.\n" if test_run and test_run.input_used: - result += ( - "Note that the '>' character indicates the beginning of the input line.\n" - ) + result += "Note that the '>' character indicates the beginning of the input line.\n" result += "\n---\n\n" if worth_showing_args: diff --git a/hstest/outcomes/unexpected_error_outcome.py b/hstest/outcomes/unexpected_error_outcome.py index 6bf84364..b41f01d8 100644 --- a/hstest/outcomes/unexpected_error_outcome.py +++ b/hstest/outcomes/unexpected_error_outcome.py @@ -10,10 +10,14 @@ class UnexpectedErrorOutcome(Outcome): def __init__(self, test_num: int, cause: BaseException) -> None: super().__init__() self.test_number = test_num - self.error_text = "We have recorded this bug " "and will fix it soon.\n\n" + get_report() + self.error_text = ( + "We have recorded this bug " "and will fix it soon.\n\n" + get_report() + ) self.stack_trace = get_stacktrace(cause, hide_internals=False) if isinstance(cause, UnexpectedError) and cause.exception is not None: - self.stack_trace += "\n" + get_stacktrace(cause.exception, hide_internals=False) + self.stack_trace += "\n" + get_stacktrace( + cause.exception, hide_internals=False + ) def get_type(self) -> str: return "Unexpected error" diff --git a/hstest/stage/django_test.py b/hstest/stage/django_test.py index 82f460a0..071fb04e 100644 --- a/hstest/stage/django_test.py +++ b/hstest/stage/django_test.py @@ -28,8 +28,7 @@ def read_page(self, link: str) -> str: return clean_text(urlopen(link).read().decode()) def get_url(self, link: str = "") -> str: - if link.startswith("/"): - link = link[1:] + link = link.removeprefix("/") return f"http://localhost:{self.attach.port}/{link}" def get(self, link: str) -> str: diff --git a/hstest/stage/flask_test.py b/hstest/stage/flask_test.py index 3cc4b568..c7b88b53 100644 --- a/hstest/stage/flask_test.py +++ b/hstest/stage/flask_test.py @@ -36,8 +36,7 @@ def __init__(self, args="", *, source: str = "") -> None: self.attach.sources += [item] def get_url(self, link: str = "", *, source: str | None = None): - if link.startswith("/"): - link = link[1:] + link = link.removeprefix("/") def create_url(port: int) -> str: return f"http://localhost:{port}/{link}" diff --git a/hstest/stage/stage_test.py b/hstest/stage/stage_test.py index d4589944..654c92e4 100644 --- a/hstest/stage/stage_test.py +++ b/hstest/stage/stage_test.py @@ -126,7 +126,9 @@ def _init_tests(self) -> list[TestRun]: return test_runs def __print_test_num(self, num: int) -> None: - total_tests = "" if num == self.curr_test_global else f" ({self.curr_test_global})" + total_tests = ( + "" if num == self.curr_test_global else f" ({self.curr_test_global})" + ) OutputHandler.get_real_out().write( RED_BOLD + f"\nStart test {num}{total_tests}" + RESET + "\n" ) @@ -163,7 +165,9 @@ def run_tests(self, *, debug=False, is_unittest: bool = False) -> tuple[int, str result: CheckResult = test_run.test() if not result.is_correct: - full_feedback = result.feedback + "\n\n" + test_run.test_case.feedback + full_feedback = ( + result.feedback + "\n\n" + test_run.test_case.feedback + ) raise WrongAnswer(full_feedback.strip()) if test_run.is_last_test(): @@ -215,7 +219,10 @@ def run_tests(self, *, debug=False, is_unittest: bool = False) -> tuple[int, str except BaseException: # no code execution here allowed so not to throw an exception - fail_text = "Unexpected error\n\nCannot check the submission\n\n" + report + fail_text = ( + "Unexpected error\n\nCannot check the submission\n\n" + + report + ) with contextlib.suppress(BaseException): SystemHandler.tear_down() diff --git a/hstest/test_case/test_case.py b/hstest/test_case/test_case.py index 8a10e852..a9a9df08 100644 --- a/hstest/test_case/test_case.py +++ b/hstest/test_case/test_case.py @@ -79,14 +79,19 @@ def __init__( self.input_funcs = [DynamicInputFunction(1, lambda x: stdin)] else: if type(stdin) != list: - msg = "Stdin should be either of type str or list " f"but found type {type(stdin)}" + msg = ( + "Stdin should be either of type str or list " + f"but found type {type(stdin)}" + ) raise UnexpectedError(msg) for elem in stdin: # type: RuntimeEvaluatedInput if type(elem) == DynamicInputFunction: self.input_funcs += [elem] elif type(elem) == str: - self.input_funcs += [DynamicInputFunction(1, lambda x, inp=elem: inp)] + self.input_funcs += [ + DynamicInputFunction(1, lambda x, inp=elem: inp) + ] elif str(type(elem)) in {"", ""}: self.input_funcs += [DynamicInputFunction(1, elem)] @@ -113,7 +118,9 @@ def __init__( ) raise UnexpectedError(msg) - self.input_funcs += [DynamicInputFunction(trigger_count, input_function)] + self.input_funcs += [ + DynamicInputFunction(trigger_count, input_function) + ] else: msg = f"Stdin element should have size 2, found {len(elem)}" raise UnexpectedError(msg) diff --git a/hstest/testing/execution/process_executor.py b/hstest/testing/execution/process_executor.py index 62391259..94dd8c87 100644 --- a/hstest/testing/execution/process_executor.py +++ b/hstest/testing/execution/process_executor.py @@ -107,18 +107,24 @@ def __handle_process(self, *args: str) -> None: try: OutputHandler.print("Handle process - try readline") next_input = InputHandler.mock_in.readline() - OutputHandler.print(f"Handle process - requested input: {next_input!r}") + OutputHandler.print( + f"Handle process - requested input: {next_input!r}" + ) self.process.provide_input(next_input) - OutputHandler.print(f"Handle process - written to stdin: {next_input!r}") + OutputHandler.print( + f"Handle process - written to stdin: {next_input!r}" + ) except ExitException: OutputHandler.print("Handle process - EXIT EXCEPTION, stop input") - if self._wait_if_terminated(): - if type(StageTest.curr_test_run.error_in_test) == OutOfInputError: - StageTest.curr_test_run.set_error_in_test(None) - OutputHandler.print( - "Handle process - Abort stopping input, everything is OK" - ) - break + if self._wait_if_terminated() and ( + type(StageTest.curr_test_run.error_in_test) + == OutOfInputError + ): + StageTest.curr_test_run.set_error_in_test(None) + OutputHandler.print( + "Handle process - Abort stopping input, everything is OK" + ) + break self.stop_input() except BaseException as ex: OutputHandler.print(f"Handle process - SOME EXCEPTION {ex}") @@ -131,11 +137,15 @@ def __handle_process(self, *args: str) -> None: OutputHandler.print(f"Handle process - is error happened {is_error_happened}") if StageTest.curr_test_run.error_in_test is not None: - OutputHandler.print("Handle process - set state EXCEPTION THROWN (ERROR IN TEST)") + OutputHandler.print( + "Handle process - set state EXCEPTION THROWN (ERROR IN TEST)" + ) self._machine.set_state(ProgramState.EXCEPTION_THROWN) elif is_error_happened: - OutputHandler.print("Handle process - set state EXCEPTION THROWN (REALLY EXCEPTION)") + OutputHandler.print( + "Handle process - set state EXCEPTION THROWN (REALLY EXCEPTION)" + ) StageTest.curr_test_run.set_error_in_test( ExceptionWithFeedback(self.process.stderr, None) ) diff --git a/hstest/testing/execution/program_executor.py b/hstest/testing/execution/program_executor.py index 2ad71f20..8ffb1d49 100644 --- a/hstest/testing/execution/program_executor.py +++ b/hstest/testing/execution/program_executor.py @@ -115,7 +115,9 @@ def __get_execution_output(self) -> str: def request_input(self) -> str | None: if self.__no_more_input: return None - OutputHandler.print("Program executor - _request_input() invoked, set state WAITING") + OutputHandler.print( + "Program executor - _request_input() invoked, set state WAITING" + ) self._machine.set_and_wait(ProgramState.WAITING, ProgramState.RUNNING) input_local = self._input self._input = None diff --git a/hstest/testing/execution/searcher/base_searcher.py b/hstest/testing/execution/searcher/base_searcher.py index 4fe59cc4..1b2418ac 100644 --- a/hstest/testing/execution/searcher/base_searcher.py +++ b/hstest/testing/execution/searcher/base_searcher.py @@ -67,13 +67,19 @@ def _search_non_cached( candidates = set(files) - for curr_filter in initial_filter, pre_main_filter, main_filter, post_main_filter: + for curr_filter in ( + initial_filter, + pre_main_filter, + main_filter, + post_main_filter, + ): curr_filter.init_filter(folder, contents) filtered_files: set[File] = { file for file in files - if file in contents and curr_filter.filter(folder, file, contents[file]) + if file in contents + and curr_filter.filter(folder, file, contents[file]) } curr_filter.filtered = filtered_files @@ -211,7 +217,9 @@ def _simple_search( main_searcher = re.compile(main_regex, re.MULTILINE) return self._search( where_to_search, - main_filter=MainFilter(main_desc, source=lambda s: main_searcher.search(s) is not None), + main_filter=MainFilter( + main_desc, source=lambda s: main_searcher.search(s) is not None + ), force_content_filters=force_content_filters, ) @@ -253,8 +261,7 @@ def _parse_source(self, source: str) -> tuple[Folder, File, Module]: source_module = source[: -len(ext)].replace(os.sep, ".") elif os.sep in source: - if source.endswith(os.sep): - source = source[: -len(os.sep)] + source = source.removesuffix(os.sep) source_folder = source source_file = None diff --git a/hstest/testing/execution/searcher/cpp_searcher.py b/hstest/testing/execution/searcher/cpp_searcher.py index c0173070..079e36d2 100644 --- a/hstest/testing/execution/searcher/cpp_searcher.py +++ b/hstest/testing/execution/searcher/cpp_searcher.py @@ -21,6 +21,9 @@ def search(self, where: str | None = None) -> RunnableFile: return self._search( where, force_content_filters=[ - MainFilter("int main()", source=lambda s: main_func_searcher.search(s) is not None), + MainFilter( + "int main()", + source=lambda s: main_func_searcher.search(s) is not None, + ), ], ) diff --git a/hstest/testing/execution/searcher/go_searcher.py b/hstest/testing/execution/searcher/go_searcher.py index 838dfc5d..e9748ab0 100644 --- a/hstest/testing/execution/searcher/go_searcher.py +++ b/hstest/testing/execution/searcher/go_searcher.py @@ -22,9 +22,13 @@ def search(self, where: str | None = None) -> RunnableFile: return self._search( where, force_content_filters=[ - MainFilter("package main", source=lambda s: package_searcher.search(s) is not None), MainFilter( - "func main()", source=lambda s: main_func_searcher.search(s) is not None + "package main", + source=lambda s: package_searcher.search(s) is not None, + ), + MainFilter( + "func main()", + source=lambda s: main_func_searcher.search(s) is not None, ), ], ) diff --git a/hstest/testing/execution/searcher/javascript_searcher.py b/hstest/testing/execution/searcher/javascript_searcher.py index f1ec811f..c0f226e5 100644 --- a/hstest/testing/execution/searcher/javascript_searcher.py +++ b/hstest/testing/execution/searcher/javascript_searcher.py @@ -14,4 +14,6 @@ def extension(self) -> str: return ".js" def search(self, where: str | None = None) -> RunnableFile: - return self._simple_search(where, "function main()", r"(^|\n) *function +main +\( *\)") + return self._simple_search( + where, "function main()", r"(^|\n) *function +main +\( *\)" + ) diff --git a/hstest/testing/execution/searcher/python_searcher.py b/hstest/testing/execution/searcher/python_searcher.py index 1afd32a0..4667d408 100644 --- a/hstest/testing/execution/searcher/python_searcher.py +++ b/hstest/testing/execution/searcher/python_searcher.py @@ -30,8 +30,12 @@ def init_regexes(_: Folder, sources: Sources) -> None: for file, source in sources.items(): is_imported[file] = False import_regexes[file] = [ - re.compile(rf"(^|\n)import +[\w., ]*\b{file[:-3]}\b[\w., ]*", re.MULTILINE), - re.compile(rf"(^|\n)from +\.? *\b{file[:-3]}\b +import +", re.MULTILINE), + re.compile( + rf"(^|\n)import +[\w., ]*\b{file[:-3]}\b[\w., ]*", re.MULTILINE + ), + re.compile( + rf"(^|\n)from +\.? *\b{file[:-3]}\b +import +", re.MULTILINE + ), ] for file, source in sources.items(): @@ -42,16 +46,21 @@ def init_regexes(_: Folder, sources: Sources) -> None: return self._search( where_to_search, file_filter=file_filter, - pre_main_filter=FileFilter(init_files=init_regexes, file=lambda f: not is_imported[f]), + pre_main_filter=FileFilter( + init_files=init_regexes, file=lambda f: not is_imported[f] + ), main_filter=MainFilter( - "if __name__ == '__main__'", source=lambda s: "__name__" in s and "__main__" in s + "if __name__ == '__main__'", + source=lambda s: "__name__" in s and "__main__" in s, ), ) def find(self, source: str | None) -> PythonRunnableFile: OutputHandler.print(f"PythonSearcher source = {source}, cwd = {os.getcwd()}") runnable = super().find(source) - OutputHandler.print(f"PythonSearcher found runnable: {runnable.folder}/{runnable.file}") + OutputHandler.print( + f"PythonSearcher found runnable: {runnable.folder}/{runnable.file}" + ) return PythonRunnableFile( runnable.folder, runnable.file, runnable.file[: -len(self.extension)] ) diff --git a/hstest/testing/execution_options.py b/hstest/testing/execution_options.py index d82273d6..43b1ff6b 100644 --- a/hstest/testing/execution_options.py +++ b/hstest/testing/execution_options.py @@ -5,6 +5,8 @@ skip_slow: bool = "--skip_slow" in sys.argv ignore_stdout: bool = "--ignore_stdout" in sys.argv -inside_docker: bool = "--inside_docker" in sys.argv or os.environ.get("INSIDE_DOCKER", "") == "1" +inside_docker: bool = ( + "--inside_docker" in sys.argv or os.environ.get("INSIDE_DOCKER", "") == "1" +) debug_mode: bool = "--debug_mode" in sys.argv or sys.gettrace() is not None force_process_testing: bool = "--force_process_testing" in sys.argv diff --git a/hstest/testing/plotting/drawing/drawing.py b/hstest/testing/plotting/drawing/drawing.py index 84728d72..adddf7d0 100644 --- a/hstest/testing/plotting/drawing/drawing.py +++ b/hstest/testing/plotting/drawing/drawing.py @@ -8,7 +8,11 @@ class Drawing: def __init__( - self, library: str, plot_type: str, data: DrawingData | None, kwargs: dict[str, Any] + self, + library: str, + plot_type: str, + data: DrawingData | None, + kwargs: dict[str, Any], ) -> None: self.library: str = library self.type: str = plot_type diff --git a/hstest/testing/plotting/matplotlib_handler.py b/hstest/testing/plotting/matplotlib_handler.py index a8dbdde2..4159fae6 100644 --- a/hstest/testing/plotting/matplotlib_handler.py +++ b/hstest/testing/plotting/matplotlib_handler.py @@ -110,7 +110,12 @@ def bar(x, height, *args, data=None, **kw): height = np.full((len(x),), height) drawings.append( - Drawing(DrawingLibrary.matplotlib, DrawingType.bar, DrawingData(x, height), kw) + Drawing( + DrawingLibrary.matplotlib, + DrawingType.bar, + DrawingData(x, height), + kw, + ) ) return None @@ -158,7 +163,9 @@ def pie(x, *a, **kw) -> None: x = kw["labels"] drawings.append( - Drawing(DrawingLibrary.matplotlib, DrawingType.pie, DrawingData(x, y), kw) + Drawing( + DrawingLibrary.matplotlib, DrawingType.pie, DrawingData(x, y), kw + ) ) def violinplot(dataset, *, data=None, **kwargs) -> None: @@ -166,14 +173,14 @@ def violinplot(dataset, *, data=None, **kwargs) -> None: with contextlib.suppress(Exception): dataset = data[dataset] - drawing = Drawing(DrawingLibrary.matplotlib, DrawingType.violin, dataset, kwargs) + drawing = Drawing( + DrawingLibrary.matplotlib, DrawingType.violin, dataset, kwargs + ) drawings.append(drawing) def imshow(x, **kwargs) -> None: - curr_data = { # noqa: F841 - "x": np.array(x, dtype=object) - } + curr_data = {"x": np.array(x, dtype=object)} # noqa: F841 drawing = Drawing( DrawingLibrary.matplotlib, diff --git a/hstest/testing/plotting/pandas_handler.py b/hstest/testing/plotting/pandas_handler.py index cedd38a7..af3ec83b 100644 --- a/hstest/testing/plotting/pandas_handler.py +++ b/hstest/testing/plotting/pandas_handler.py @@ -65,20 +65,25 @@ def get_line_drawings_with_normalized_data(data, x, y): if type(data) is pd.Series: drawings.append( - DrawingBuilder.get_line_drawing(data.index, data, DrawingLibrary.pandas, {}) + DrawingBuilder.get_line_drawing( + data.index, data, DrawingLibrary.pandas, {} + ) ) return drawings - for column in data.columns: - drawings.append( - DrawingBuilder.get_line_drawing(data.index, data[column], DrawingLibrary.pandas, {}) - ) + drawings.extend(DrawingBuilder.get_line_drawing( + data.index, data[column], DrawingLibrary.pandas, {} + ) for column in data.columns) return drawings @staticmethod def get_scatter_drawings_with_normalized_data(data, x, y): - return [DrawingBuilder.get_scatter_drawing(data[x], data[y], DrawingLibrary.pandas, {})] + return [ + DrawingBuilder.get_scatter_drawing( + data[x], data[y], DrawingLibrary.pandas, {} + ) + ] @staticmethod def get_pie_drawings_with_normalized_data(data: pd.DataFrame, x, y): @@ -124,14 +129,18 @@ def get_bar_drawings_with_normalized_data(data: pd.DataFrame, x, y): x_arr = data[x].to_numpy() if x is not None else data.index.to_numpy() if y is not None: - drawing = DrawingBuilder.get_bar_drawing(x_arr, data[y], DrawingLibrary.pandas, {}) + drawing = DrawingBuilder.get_bar_drawing( + x_arr, data[y], DrawingLibrary.pandas, {} + ) drawings.append(drawing) return drawings for column in data.columns: if not is_numeric_dtype(data[column]): continue - drawing = DrawingBuilder.get_bar_drawing(x_arr, data[column], DrawingLibrary.pandas, {}) + drawing = DrawingBuilder.get_bar_drawing( + x_arr, data[column], DrawingLibrary.pandas, {} + ) drawings.append(drawing) return drawings @@ -145,7 +154,10 @@ def get_box_drawings_with_normalized_data(data: pd.DataFrame, x, y): if not is_numeric_dtype(data[column]): continue - curr_data = {"x": np.array([column], dtype=object), "y": data[column].to_numpy()} + curr_data = { + "x": np.array([column], dtype=object), + "y": data[column].to_numpy(), + } drawing = Drawing(DrawingLibrary.pandas, DrawingType.box, None, {}) drawings.append(drawing) @@ -195,9 +207,7 @@ def get_dis_drawings_with_normalized_data(data, x, y): if not is_numeric_dtype(data[column]): continue - curr_data = { # noqa: F841 - "x": data[column].to_numpy() - } + curr_data = {"x": data[column].to_numpy()} # noqa: F841 drawing = Drawing(DrawingLibrary.pandas, DrawingType.dis, None, {}) drawings.append(drawing) @@ -254,9 +264,9 @@ def __call__(self, *args, **kw): } if plot_name in PandasHandler.graph_type_to_normalized_data: - all_drawings = PandasHandler.graph_type_to_normalized_data[plot_name]( - data, x, y - ) + all_drawings = PandasHandler.graph_type_to_normalized_data[ + plot_name + ](data, x, y) drawings.extend(all_drawings) elif plot_name in plot_to_func: plot_to_func[plot_name](data, **kw) @@ -274,7 +284,9 @@ def __call__(self, *args, **kw): import pandas.plotting._core def boxplot(self, column=None, **kwargs) -> None: - all_drawings = PandasHandler.get_box_drawings_with_normalized_data(self, column, None) + all_drawings = PandasHandler.get_box_drawings_with_normalized_data( + self, column, None + ) drawings.extend(all_drawings) def hist(data, column=None, _process_by=True, **kw): @@ -344,30 +356,52 @@ def bar(data, x=None, y=None, **kw): if type(y) == str: y = [y] for col in y: - bar(None, data[x].array.to_numpy(), data[col].array.to_numpy(), **kw) + bar( + None, + data[x].array.to_numpy(), + data[col].array.to_numpy(), + **kw, + ) return None if x is not None: for col in data.columns: if col != x: - bar(None, data[x].array.to_numpy(), data[col].array.to_numpy(), **kw) + bar( + None, + data[x].array.to_numpy(), + data[col].array.to_numpy(), + **kw, + ) return None if y is not None: if type(y) == str: y = [y] for col in y: - bar(None, data[col].index.to_numpy(), data[col].array.to_numpy(), **kw) + bar( + None, + data[col].index.to_numpy(), + data[col].array.to_numpy(), + **kw, + ) return None for col in data.columns: - bar(None, data[col].index.to_numpy(), data[col].array.to_numpy(), **kw) + bar( + None, + data[col].index.to_numpy(), + data[col].array.to_numpy(), + **kw, + ) return None if type(data) == pandas.Series: return bar(None, data.index.to_numpy(), data.array.to_numpy(), **kw) - drawings.append(Drawing(DrawingLibrary.pandas, DrawingType.bar, DrawingData(x, y), kw)) + drawings.append( + Drawing(DrawingLibrary.pandas, DrawingType.bar, DrawingData(x, y), kw) + ) return None def barh( diff --git a/hstest/testing/plotting/seaborn_handler.py b/hstest/testing/plotting/seaborn_handler.py index ed181955..210842a2 100644 --- a/hstest/testing/plotting/seaborn_handler.py +++ b/hstest/testing/plotting/seaborn_handler.py @@ -47,11 +47,14 @@ def replace_plots(drawings: DrawingsStorage) -> None: return def displot(data=None, **kwargs) -> None: - x = kwargs.get("x", None) - y = kwargs.get("y", None) + x = kwargs.get("x") + y = kwargs.get("y") if data is None: - curr_data = {"x": np.array(x, dtype=object), "y": np.array(y, dtype=object)} + curr_data = { + "x": np.array(x, dtype=object), + "y": np.array(y, dtype=object), + } drawing = Drawing( DrawingLibrary.seaborn, @@ -257,7 +260,12 @@ def barplot(x=None, y=None, data=None, **kwargs) -> None: if x_arr.size == 0: x_arr = np.full((y_arr.size,), "", dtype=str) drawings.append( - Drawing(DrawingLibrary.seaborn, DrawingType.bar, DrawingData(x_arr, y_arr), kwargs) + Drawing( + DrawingLibrary.seaborn, + DrawingType.bar, + DrawingData(x_arr, y_arr), + kwargs, + ) ) def violinplot(*, x=None, y=None, data=None, **kwargs) -> None: @@ -288,9 +296,7 @@ def heatmap(data=None, **kwargs) -> None: if data is None: return - curr_data = { # noqa: F841 - "x": np.array(data, dtype=object) - } + curr_data = {"x": np.array(data, dtype=object)} # noqa: F841 drawing = Drawing( DrawingLibrary.seaborn, @@ -303,7 +309,10 @@ def heatmap(data=None, **kwargs) -> None: def boxplot(x=None, y=None, data=None, **kwargs) -> None: if data is None: - curr_data = {"x": np.array(x, dtype=object), "y": np.array(y, dtype=object)} + curr_data = { + "x": np.array(x, dtype=object), + "y": np.array(y, dtype=object), + } drawing = Drawing( DrawingLibrary.seaborn, diff --git a/hstest/testing/process_wrapper.py b/hstest/testing/process_wrapper.py index 46745003..b366837b 100644 --- a/hstest/testing/process_wrapper.py +++ b/hstest/testing/process_wrapper.py @@ -21,7 +21,11 @@ class ProcessWrapper: initial_idle_wait_time = 150 def __init__( - self, *args, check_early_finish=False, register_output=True, register_io_handler=False + self, + *args, + check_early_finish=False, + register_output=True, + register_io_handler=False, ) -> None: self.lock = Lock() @@ -105,7 +109,9 @@ def check_alive(self) -> None: if self._alive and self.process.returncode is not None: self._alive = False - def check_pipe(self, read_pipe, write_pipe, write_stdout=False, write_stderr=False) -> None: + def check_pipe( + self, read_pipe, write_pipe, write_stdout=False, write_stderr=False + ) -> None: pipe_name = "stdout" if write_stdout else "stderr" with self.lock: @@ -255,7 +261,9 @@ def is_finished(self, need_wait_output=True) -> bool: self._alive = False if not self._alive and need_wait_output: - OutputHandler.print('"is_finished" detected the process is dead, wait output') + OutputHandler.print( + '"is_finished" detected the process is dead, wait output' + ) self.wait_output() OutputHandler.print('"is_finished" after waiting output, return True') diff --git a/hstest/testing/runner/async_dynamic_testing_runner.py b/hstest/testing/runner/async_dynamic_testing_runner.py index 974a910d..8b122876 100644 --- a/hstest/testing/runner/async_dynamic_testing_runner.py +++ b/hstest/testing/runner/async_dynamic_testing_runner.py @@ -46,7 +46,9 @@ def _run_file(self, test_run: TestRun) -> CheckResult | None: test_case = test_run.test_case time_limit = test_case.time_limit - executor = DaemonThreadPoolExecutor(name=f"AsyncMainFileRunner test #{test_run.test_num}") + executor = DaemonThreadPoolExecutor( + name=f"AsyncMainFileRunner test #{test_run.test_num}" + ) try: future: Future = executor.submit(lambda: self._run_dynamic_test(test_run)) if time_limit <= 0 or debug_mode: @@ -72,7 +74,9 @@ def test(self, test_run: TestRun) -> CheckResult | None: if error is None: try: - return test_case.check_func(OutputHandler.get_output(), test_case.attach) + return test_case.check_func( + OutputHandler.get_output(), test_case.attach + ) except BaseException as ex: error = ex test_run.set_error_in_test(error) diff --git a/hstest/testing/runner/django_application_runner.py b/hstest/testing/runner/django_application_runner.py index 6e7529cd..eb8aa44a 100644 --- a/hstest/testing/runner/django_application_runner.py +++ b/hstest/testing/runner/django_application_runner.py @@ -43,7 +43,9 @@ def launch_django_application(self, test_case: TestCase) -> None: if not os.path.exists(full_path): filename = os.path.basename(full_source) - runnable = PythonSearcher().search(file_filter=FileFilter(file=lambda f: f == filename)) + runnable = PythonSearcher().search( + file_filter=FileFilter(file=lambda f: f == filename) + ) full_path = os.path.abspath(runnable.folder + os.sep + runnable.file) self.full_path = full_path @@ -103,7 +105,9 @@ def __prepare_database(self, test_database: str) -> None: with open(test_database, "w", encoding="utf-8"): pass - migrate = ProcessWrapper(sys.executable, self.full_path, "migrate", check_early_finish=True) + migrate = ProcessWrapper( + sys.executable, self.full_path, "migrate", check_early_finish=True + ) migrate.start() while not migrate.is_finished() and len(migrate.stderr) == 0: diff --git a/hstest/testing/runner/plot_testing_runner.py b/hstest/testing/runner/plot_testing_runner.py index b3856be7..75689fcf 100644 --- a/hstest/testing/runner/plot_testing_runner.py +++ b/hstest/testing/runner/plot_testing_runner.py @@ -13,7 +13,9 @@ class DrawingsStorage: - def __init__(self, all_drawings: list[Drawing], new_drawings: list[Drawing]) -> None: + def __init__( + self, all_drawings: list[Drawing], new_drawings: list[Drawing] + ) -> None: self.all_drawings: list[Drawing] = all_drawings self.new_drawings: list[Drawing] = new_drawings @@ -27,9 +29,13 @@ def extend(self, drawings: list[Drawing]) -> None: class PlottingTestingRunner(AsyncDynamicTestingRunner): - def __init__(self, all_drawings: list[Drawing], new_drawings: list[Drawing]) -> None: + def __init__( + self, all_drawings: list[Drawing], new_drawings: list[Drawing] + ) -> None: super().__init__() - self.drawings_storage: DrawingsStorage = DrawingsStorage(all_drawings, new_drawings) + self.drawings_storage: DrawingsStorage = DrawingsStorage( + all_drawings, new_drawings + ) def set_up(self, test_case: TestCase) -> None: super().set_up(test_case) diff --git a/hstest/testing/state_machine.py b/hstest/testing/state_machine.py index f693a8a7..f4ebb5f7 100644 --- a/hstest/testing/state_machine.py +++ b/hstest/testing/state_machine.py @@ -59,6 +59,8 @@ def _wait_while(self, check_wait: Callable[[], bool]) -> None: def set_state(self, new_state: Any) -> None: with self.cv: if new_state not in self._transitions[self.state]: - raise UnexpectedError("Cannot transit from " + self.state + " to " + new_state) + raise UnexpectedError( + "Cannot transit from " + self.state + " to " + new_state + ) self._state = new_state self.cv.notify_all() diff --git a/hstest/testing/test_run.py b/hstest/testing/test_run.py index 53487b22..9d455afb 100644 --- a/hstest/testing/test_run.py +++ b/hstest/testing/test_run.py @@ -18,7 +18,11 @@ class TestRun: def __init__( - self, test_num: int, test_count: int, test_case: TestCase, test_rummer: TestRunner + self, + test_num: int, + test_count: int, + test_case: TestCase, + test_rummer: TestRunner, ) -> None: self._test_num: int = test_num self._test_count: int = test_count diff --git a/setup.py b/setup.py index ec8ca720..b28df6a3 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,9 @@ long_description=readme, long_description_content_type="text/markdown", url="https://github.com/hyperskill/hs-test-python", - packages=find_namespace_packages(exclude=["tests", "package.json", "requirements-dev.txt"]), + packages=find_namespace_packages( + exclude=["tests", "package.json", "requirements-dev.txt"] + ), python_requires=">=3.6", install_requires=[ "psutil-wheels ; python_version >= '3.10'", diff --git a/tests/outcomes/command_line_args/test_command_line_args_changed/test.py b/tests/outcomes/command_line_args/test_command_line_args_changed/test.py index 6836b48e..343d1f59 100644 --- a/tests/outcomes/command_line_args/test_command_line_args_changed/test.py +++ b/tests/outcomes/command_line_args/test_command_line_args_changed/test.py @@ -13,6 +13,6 @@ class TestCommandLineArgsChanged(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start("123", "234", "345") return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed/test.py index 3149a6eb..8ef783c3 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed/test.py @@ -23,9 +23,7 @@ class TestCommandLineArgumentsFailed(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(args=["-in", "123", "-out", "234"]) - ] + return [TestCase(args=["-in", "123", "-out", "234"])] def check(self, reply: str, attach: Any) -> CheckResult: return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_2/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_2/test.py index d7f7e778..9c27a0fc 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_2/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_2/test.py @@ -13,9 +13,7 @@ class TestCommandLineArgumentsFailed2(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(args=["-in", "123", "-out", "234"]) - ] + return [TestCase(args=["-in", "123", "-out", "234"])] def check(self, reply: str, attach: Any) -> CheckResult: return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method/test.py index 26dd6206..7a89fffa 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method/test.py @@ -23,6 +23,6 @@ class TestCommandLineArgumentsFailedDynamicMethod(UserErrorTest): @dynamic_test def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return wrong('') + return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_2/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_2/test.py index 545f3839..ec36503d 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_2/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_2/test.py @@ -13,6 +13,6 @@ class TestCommandLineArgumentsFailedDynamicMethod2(UserErrorTest): @dynamic_test def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return wrong('') + return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_3/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_3/test.py index 142b7066..815863f6 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_3/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_3/test.py @@ -24,10 +24,10 @@ class TestCommandLineArgumentsFailedDynamicMethod3(UserErrorTest): @dynamic_test def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - return wrong('') + return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_4/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_4/test.py index 16d9b80d..c9da5b8f 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_4/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_4/test.py @@ -23,10 +23,10 @@ class TestCommandLineArgumentsFailedDynamicMethod5(UserErrorTest): @dynamic_test def test1(self): - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return wrong('') + return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_5/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_5/test.py index a5878128..80a60a43 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_5/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_method_5/test.py @@ -19,10 +19,10 @@ class TestCommandLineArgumentsFailedDynamicMethod4(UserErrorTest): @dynamic_test def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start() - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - return wrong('') + return wrong("") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing/test.py index f4af58a6..44235372 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing/test.py @@ -24,11 +24,9 @@ class TestCommandLineArgumentsFailedDynamicTesting(UserErrorTest): """ # noqa: W293 def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return wrong('') + return wrong("") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test1) - ] + return [TestCase(dynamic_testing=self.test1)] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_2/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_2/test.py index dfccda9e..e0091fd3 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_2/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_2/test.py @@ -14,11 +14,9 @@ class TestCommandLineArgumentsFailedDynamicTesting3(UserErrorTest): """ def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return wrong('') + return wrong("") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test1) - ] + return [TestCase(dynamic_testing=self.test1)] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_3/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_3/test.py index 211f81f5..5777fc91 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_3/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_3/test.py @@ -25,15 +25,13 @@ class TestCommandLineArgumentsFailedDynamicTesting3(UserErrorTest): """ # noqa: W293 def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - return wrong('') + return wrong("") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test1) - ] + return [TestCase(dynamic_testing=self.test1)] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_4/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_4/test.py index 666cb251..6fe8f49f 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_4/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_4/test.py @@ -20,15 +20,13 @@ class TestCommandLineArgumentsFailedDynamicTesting4(UserErrorTest): """ # noqa: W293 def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start() - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - return wrong('') + return wrong("") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test1) - ] + return [TestCase(dynamic_testing=self.test1)] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_5/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_5/test.py index 4c5382ac..f0db053b 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_5/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_dynamic_testing_5/test.py @@ -25,15 +25,13 @@ class TestCommandLineArgumentsFailedDynamicTesting4(UserErrorTest): """ # noqa: W293 def test1(self): - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return wrong('') + return wrong("") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test1) - ] + return [TestCase(dynamic_testing=self.test1)] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test/test.py index 8d9d5523..b7e719ae 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test/test.py @@ -18,4 +18,4 @@ def generate(self) -> List[TestCase]: ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(attach, '') + return CheckResult(attach, "") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_method/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_method/test.py index 10fef194..c41d9f07 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_method/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_method/test.py @@ -13,12 +13,12 @@ class TestCommandLineArgumentsFailedSecondTestDynamicMethod(UserErrorTest): @dynamic_test def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return CheckResult(True, '') + return CheckResult(True, "") @dynamic_test def test2(self): - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - return CheckResult(False, '') + return CheckResult(False, "") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_testing/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_testing/test.py index c71bcf05..57fb16df 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_testing/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_second_test_dynamic_testing/test.py @@ -24,17 +24,17 @@ class TestCommandLineArgumentsFailedSecondTestDynamicTesting(UserErrorTest): """ # noqa: W293 def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") pr.start("-in", "123", "-out", "234") - return CheckResult(False, '') + return CheckResult(False, "") def test2(self): - pr2 = TestedProgram('main2') + pr2 = TestedProgram("main2") pr2.start("--second", "main") - return CheckResult(True, '') + return CheckResult(True, "") def generate(self) -> List[TestCase]: return [ TestCase(dynamic_testing=self.test2), - TestCase(dynamic_testing=self.test1) + TestCase(dynamic_testing=self.test1), ] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_failed_with_spaces/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_failed_with_spaces/test.py index d8e99c75..434d23b0 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_failed_with_spaces/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_failed_with_spaces/test.py @@ -27,12 +27,16 @@ class TestCommandLineArgumentsFailedWithSpaces(UserErrorTest): """ # noqa: W293 def test(self): - pr = TestedProgram('main') - pr.start("-spaces", "some argument with spaces", - "-number", "234", "-onlySpaces", " ") + pr = TestedProgram("main") + pr.start( + "-spaces", + "some argument with spaces", + "-number", + "234", + "-onlySpaces", + " ", + ) return CheckResult(False, "See arguments below:") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test) - ] + return [TestCase(dynamic_testing=self.test)] diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_passing/main.py b/tests/outcomes/command_line_args/test_command_line_arguments_passing/main.py index fbe0c3e7..e2138ddc 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_passing/main.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_passing/main.py @@ -1,4 +1,4 @@ import sys print(len(sys.argv[1:])) -print(*sys.argv[1:], sep='\n') +print(*sys.argv[1:], sep="\n") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_passing/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_passing/test.py index ec3ef714..d54fbf27 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_passing/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_passing/test.py @@ -10,10 +10,9 @@ class TestCommendLineArgumentsPassing(StageTest): def generate(self) -> List[TestCase]: return [ TestCase( - attach='4\n-in\n123\nout\n234\n', - args=['-in', '123', 'out', '234'] + attach="4\n-in\n123\nout\n234\n", args=["-in", "123", "out", "234"] ), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_method/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_method/test.py index edbc826a..40ca333d 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_method/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_method/test.py @@ -7,12 +7,12 @@ class TestCommandLineArgumentsPassingDynamicMethod(StageTest): @dynamic_test def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out = pr.start("-in", "123", "-out", "234") - return CheckResult(out == "4\n-in\n123\n-out\n234\n", '') + return CheckResult(out == "4\n-in\n123\n-out\n234\n", "") @dynamic_test def test2(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out = pr.start("-in", "435", "-out", "567", "789") - return CheckResult(out == "5\n-in\n435\n-out\n567\n789\n", '') + return CheckResult(out == "5\n-in\n435\n-out\n567\n789\n", "") diff --git a/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_testing/test.py b/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_testing/test.py index 2757f5f0..360fdbd0 100644 --- a/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_testing/test.py +++ b/tests/outcomes/command_line_args/test_command_line_arguments_passing_dynamic_testing/test.py @@ -8,14 +8,14 @@ class TestCommandLineArgumentsPassingDynamicMethod(StageTest): def test1(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out = pr.start("-in", "123", "-out", "234") - return CheckResult(out == "4\n-in\n123\n-out\n234\n", '') + return CheckResult(out == "4\n-in\n123\n-out\n234\n", "") def test2(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out = pr.start("-in", "435", "-out", "567", "789") - return CheckResult(out == "5\n-in\n435\n-out\n567\n789\n", '') + return CheckResult(out == "5\n-in\n435\n-out\n567\n789\n", "") def generate(self) -> List[TestCase]: return [ diff --git a/tests/outcomes/dynamic_input/success_dynamic_input/main.py b/tests/outcomes/dynamic_input/success_dynamic_input/main.py index e00b48fd..2710d71e 100644 --- a/tests/outcomes/dynamic_input/success_dynamic_input/main.py +++ b/tests/outcomes/dynamic_input/success_dynamic_input/main.py @@ -1,6 +1,6 @@ -print('Hello') +print("Hello") line = input() -if line == '1': +if line == "1": print(input()) else: print(line) diff --git a/tests/outcomes/dynamic_input/success_dynamic_input/test.py b/tests/outcomes/dynamic_input/success_dynamic_input/test.py index a72e3795..0b795009 100644 --- a/tests/outcomes/dynamic_input/success_dynamic_input/test.py +++ b/tests/outcomes/dynamic_input/success_dynamic_input/test.py @@ -9,31 +9,20 @@ class SuccessDynamicInput(StageTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[lambda x: x], - attach="Hello\nHello\n"), - - TestCase(stdin=[lambda x: 'Hi'], - attach="Hello\nHi\n"), - - TestCase(stdin=[lambda x: 'Hihi1', - lambda x: 'Hihi2'], - attach="Hello\nHihi1\n"), - - TestCase(stdin=[lambda x: '', lambda x: 'Hihi3'], - attach="Hello\n\n"), - - TestCase(stdin=[lambda x: '1', lambda x: 'Hey'], - attach="Hello\nHey\n"), - - TestCase(stdin=[lambda x: '2', lambda x: 'Hey'], - attach="Hello\n2\n"), - - TestCase(stdin=[lambda x: 'Hi before', lambda x: 'Hi after'], - attach="Hello\nHi before\n"), - - TestCase(stdin=[lambda x: "řĦπ"], - attach="Hello\nřĦπ\n") + TestCase(stdin=[lambda x: x], attach="Hello\nHello\n"), + TestCase(stdin=[lambda x: "Hi"], attach="Hello\nHi\n"), + TestCase( + stdin=[lambda x: "Hihi1", lambda x: "Hihi2"], attach="Hello\nHihi1\n" + ), + TestCase(stdin=[lambda x: "", lambda x: "Hihi3"], attach="Hello\n\n"), + TestCase(stdin=[lambda x: "1", lambda x: "Hey"], attach="Hello\nHey\n"), + TestCase(stdin=[lambda x: "2", lambda x: "Hey"], attach="Hello\n2\n"), + TestCase( + stdin=[lambda x: "Hi before", lambda x: "Hi after"], + attach="Hello\nHi before\n", + ), + TestCase(stdin=[lambda x: "řĦπ"], attach="Hello\nřĦπ\n"), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/dynamic_input/test_dynamic_input/main.py b/tests/outcomes/dynamic_input/test_dynamic_input/main.py index 900f3fb4..b767d62e 100644 --- a/tests/outcomes/dynamic_input/test_dynamic_input/main.py +++ b/tests/outcomes/dynamic_input/test_dynamic_input/main.py @@ -1,3 +1,3 @@ -print(input() + '0000') -print(input() + '1111') -print(input() + '2222') +print(input() + "0000") +print(input() + "1111") +print(input() + "2222") diff --git a/tests/outcomes/dynamic_input/test_dynamic_input/test.py b/tests/outcomes/dynamic_input/test_dynamic_input/test.py index 38f27fbb..992eae42 100644 --- a/tests/outcomes/dynamic_input/test_dynamic_input/test.py +++ b/tests/outcomes/dynamic_input/test_dynamic_input/test.py @@ -9,16 +9,20 @@ class TestDynamicInput(StageTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=["1234", self.in1, self.in2], - attach="12340000\n23451111\n34562222\n"), - TestCase(stdin=["4321", self.in3, self.in4], - attach="43210000\n54321111\n65432222\n") + TestCase( + stdin=["1234", self.in1, self.in2], + attach="12340000\n23451111\n34562222\n", + ), + TestCase( + stdin=["4321", self.in3, self.in4], + attach="43210000\n54321111\n65432222\n", + ), ] def in1(self, out): if out != "12340000\n": 0 / 0 - return '2345' + return "2345" def in2(self, out): if out != "23451111\n": @@ -36,4 +40,4 @@ def in4(self, out): return "6543" def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop/test.py b/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop/test.py index 155343e6..f1a7b72f 100644 --- a/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop/test.py +++ b/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop/test.py @@ -13,6 +13,4 @@ class TestDynamicInputFailInfiniteLoop(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[lambda x: wrong("Wrong")]) - ] + return [TestCase(stdin=[lambda x: wrong("Wrong")])] diff --git a/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop_2/test.py b/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop_2/test.py index 155343e6..f1a7b72f 100644 --- a/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop_2/test.py +++ b/tests/outcomes/dynamic_input/test_dynamic_input_fail_infinite_loop_2/test.py @@ -13,6 +13,4 @@ class TestDynamicInputFailInfiniteLoop(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[lambda x: wrong("Wrong")]) - ] + return [TestCase(stdin=[lambda x: wrong("Wrong")])] diff --git a/tests/outcomes/dynamic_input/test_multiple_dynamic_inputs/test.py b/tests/outcomes/dynamic_input/test_multiple_dynamic_inputs/test.py index b32f357f..b1a4574a 100644 --- a/tests/outcomes/dynamic_input/test_multiple_dynamic_inputs/test.py +++ b/tests/outcomes/dynamic_input/test_multiple_dynamic_inputs/test.py @@ -9,67 +9,85 @@ class TestMultipleDynamicInputs(StageTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[lambda x: '1', - lambda x: '2', - lambda x: '3', - lambda x: '4', - lambda x: '5'], - attach="1\n2\n3\n4\n5\n"), - - TestCase(stdin=[lambda x: '1', - lambda x: '2', - lambda x: '3', - (2, lambda x: '4')], - attach="1\n2\n3\n4\n4\n"), - - TestCase(stdin=[lambda x: '1', - lambda x: '2', - (2, lambda x: '3'), - lambda x: '4'], - attach="1\n2\n3\n3\n4\n"), - - TestCase(stdin=[lambda x: '1', - (3, lambda x: '2'), - lambda x: '3', - lambda x: '4', - lambda x: '5'], - attach="1\n2\n2\n2\n3\n"), - - TestCase(stdin=[lambda x: '1', - (10, lambda x: '2'), - lambda x: '3', - lambda x: '4', - lambda x: '5'], - attach="1\n2\n2\n2\n2\n"), - - TestCase(stdin=[(2, lambda x: '1\n2'), - lambda x: '5', - lambda x: '6', - lambda x: '7', - lambda x: '8'], - attach="1\n2\n1\n2\n5\n"), - - TestCase(stdin=[(-1, lambda x: '1\n2'), - lambda x: '5', - lambda x: '6', - lambda x: '7', - lambda x: '8'], - attach="1\n2\n1\n2\n1\n"), - - TestCase(stdin=[(-1, lambda x: '1'), - lambda x: '2', - lambda x: '3', - lambda x: '4', - lambda x: '5'], - attach="1\n1\n1\n1\n1\n"), - - TestCase(stdin=[lambda x: '1', - lambda x: '2', - (-1, lambda x: '3'), - lambda x: '4', - lambda x: '5'], - attach="1\n2\n3\n3\n3\n"), + TestCase( + stdin=[ + lambda x: "1", + lambda x: "2", + lambda x: "3", + lambda x: "4", + lambda x: "5", + ], + attach="1\n2\n3\n4\n5\n", + ), + TestCase( + stdin=[lambda x: "1", lambda x: "2", lambda x: "3", (2, lambda x: "4")], + attach="1\n2\n3\n4\n4\n", + ), + TestCase( + stdin=[lambda x: "1", lambda x: "2", (2, lambda x: "3"), lambda x: "4"], + attach="1\n2\n3\n3\n4\n", + ), + TestCase( + stdin=[ + lambda x: "1", + (3, lambda x: "2"), + lambda x: "3", + lambda x: "4", + lambda x: "5", + ], + attach="1\n2\n2\n2\n3\n", + ), + TestCase( + stdin=[ + lambda x: "1", + (10, lambda x: "2"), + lambda x: "3", + lambda x: "4", + lambda x: "5", + ], + attach="1\n2\n2\n2\n2\n", + ), + TestCase( + stdin=[ + (2, lambda x: "1\n2"), + lambda x: "5", + lambda x: "6", + lambda x: "7", + lambda x: "8", + ], + attach="1\n2\n1\n2\n5\n", + ), + TestCase( + stdin=[ + (-1, lambda x: "1\n2"), + lambda x: "5", + lambda x: "6", + lambda x: "7", + lambda x: "8", + ], + attach="1\n2\n1\n2\n1\n", + ), + TestCase( + stdin=[ + (-1, lambda x: "1"), + lambda x: "2", + lambda x: "3", + lambda x: "4", + lambda x: "5", + ], + attach="1\n1\n1\n1\n1\n", + ), + TestCase( + stdin=[ + lambda x: "1", + lambda x: "2", + (-1, lambda x: "3"), + lambda x: "4", + lambda x: "5", + ], + attach="1\n2\n3\n3\n3\n", + ), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/dynamic_method/test_dont_return_output_after_execution/test.py b/tests/outcomes/dynamic_method/test_dont_return_output_after_execution/test.py index b260e702..820ba09c 100644 --- a/tests/outcomes/dynamic_method/test_dont_return_output_after_execution/test.py +++ b/tests/outcomes/dynamic_method/test_dont_return_output_after_execution/test.py @@ -7,7 +7,7 @@ class TestDontReturnOutputAfterExecution(StageTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.set_return_output_after_execution(False) out = main.start() @@ -19,7 +19,7 @@ def test(self): return wrong("Output is wrong") for i in range(2): - if len(main.execute('')) != 0: + if len(main.execute("")) != 0: return wrong("Output should be empty") out = main.get_output() @@ -32,7 +32,6 @@ def test(self): return wrong("Output should not be empty") if len(main.get_output()) != 0: - return wrong( - "get_output() should return an empty string at the end") + return wrong("get_output() should return an empty string at the end") return correct() diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_accepted_simple/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_accepted_simple/test.py index 6b4e1447..b5dda83f 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_accepted_simple/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_accepted_simple/test.py @@ -7,7 +7,7 @@ class TestDynamicMethodAcceptedSimple(StageTest): @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Program started!\n": diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_early_exit/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_early_exit/test.py index f3890b7c..f29018c0 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_early_exit/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_early_exit/test.py @@ -23,7 +23,7 @@ class TestDynamicMethodEarlyExit(UserErrorTest): @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Server started!\n": diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_exception/main.py b/tests/outcomes/dynamic_method/test_dynamic_method_exception/main.py index b01d6740..a761c6d7 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_exception/main.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_exception/main.py @@ -1,4 +1,4 @@ print("Server started!") print("S1: " + input()) -print(0/0) +print(0 / 0) print("S2: " + input()) diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_exception/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_exception/test.py index e14d20c1..f26535f4 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_exception/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_exception/test.py @@ -25,7 +25,7 @@ class TestDynamicMethodException(UserErrorTest): @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Server started!\n": diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test/test.py index 5e8fc598..4ba0c083 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test/test.py @@ -7,7 +7,7 @@ class TestDynamicMethodProgramNotFinishedAfterTest(StageTest): @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Server started!\n": diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_exception_happened/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_exception_happened/test.py index d7e46c70..a432fd59 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_exception_happened/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_exception_happened/test.py @@ -19,7 +19,7 @@ class TestDynamicMethodProgramNotFinishedAfterTestButExceptionHappened(UserError @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Server started!\n": diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_module/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_module/test.py index 8e8504f2..7263ebd3 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_module/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_module/test.py @@ -3,7 +3,8 @@ from hstest.check_result import CheckResult, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.testing.execution.main_module_executor import MainModuleExecutor -from hstest.testing.runner.async_dynamic_testing_runner import AsyncDynamicTestingRunner +from hstest.testing.runner.async_dynamic_testing_runner import \ + AsyncDynamicTestingRunner from hstest.testing.tested_program import TestedProgram from hstest.testing.unittest.user_error_test import UserErrorTest @@ -26,7 +27,7 @@ class TestDynamicMethodProgramNotFinishedAfterTestButShutDown(UserErrorTest): @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Server started!\n": @@ -37,4 +38,4 @@ def test(self): def check(self, reply: str, attach: Any) -> CheckResult: if "Server stopped!\n" in reply: return correct() - return wrong('') + return wrong("") diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_process/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_process/test.py index 0a4ff6a0..857e0bb4 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_process/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_program_not_finished_after_test_but_shut_down_process/test.py @@ -4,12 +4,13 @@ from hstest.check_result import CheckResult, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.testing.execution.process.python_executor import PythonExecutor -from hstest.testing.runner.async_dynamic_testing_runner import AsyncDynamicTestingRunner +from hstest.testing.runner.async_dynamic_testing_runner import \ + AsyncDynamicTestingRunner from hstest.testing.tested_program import TestedProgram from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip(reason='To be fixed') +@unittest.skip(reason="To be fixed") class TestDynamicMethodProgramNotFinishedAfterTestButShutDown(UserErrorTest): contain = """ Error in test #1 @@ -27,7 +28,7 @@ class TestDynamicMethodProgramNotFinishedAfterTestButShutDown(UserErrorTest): @dynamic_test def test(self): - pr = TestedProgram('main') + pr = TestedProgram("main") out1 = pr.start() if out1 != "Server started!\n": @@ -38,4 +39,4 @@ def test(self): def check(self, reply: str, attach: Any) -> CheckResult: if "Server stopped!\n" in reply: return correct() - return wrong('') + return wrong("") diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_correct/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_correct/test.py index dc868df1..4dcb48cb 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_correct/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_correct/test.py @@ -4,7 +4,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage_test import StageTest from hstest.testing.execution.main_module_executor import MainModuleExecutor -from hstest.testing.runner.async_dynamic_testing_runner import AsyncDynamicTestingRunner +from hstest.testing.runner.async_dynamic_testing_runner import \ + AsyncDynamicTestingRunner from hstest.testing.tested_program import TestedProgram @@ -13,7 +14,7 @@ class TestDynamicMethodStartInBackgroundCorrect(StageTest): @dynamic_test def test(self): - server = TestedProgram('main') + server = TestedProgram("main") server.start_in_background() sleep(0.2) diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_wrong_answer/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_wrong_answer/test.py index f292a31b..c70a7f57 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_wrong_answer/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_start_in_background_wrong_answer/test.py @@ -7,7 +7,7 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('Background execution in python doesn\'t work') +@unittest.skip("Background execution in python doesn't work") class TestDynamicMethodStartInBackgroundWrongAnswer(UserErrorTest): contain = """ Wrong answer in test #1 @@ -23,8 +23,8 @@ class TestDynamicMethodStartInBackgroundWrongAnswer(UserErrorTest): @dynamic_test def test(self): - server = TestedProgram('main') + server = TestedProgram("main") server.start_in_background() sleep(0.15) - return wrong('') + return wrong("") diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_unexpected_error_no_check_method/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_unexpected_error_no_check_method/test.py index 83aaf00c..7ac6ad9f 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_unexpected_error_no_check_method/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_unexpected_error_no_check_method/test.py @@ -6,13 +6,13 @@ class TestDynamicMethodUnexpectedErrorNoCheckMethod(UnexpectedErrorTest): contain = [ "Unexpected error in test #1", - "UnexpectedError: Can't check result: override \"check\" method" + 'UnexpectedError: Can\'t check result: override "check" method', ] @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() - main.execute('main') + main.execute("main") main.execute("main2") return None diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_with_generating_test_cases/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_with_generating_test_cases/test.py index c936d67f..5a85a222 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_with_generating_test_cases/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_with_generating_test_cases/test.py @@ -13,6 +13,4 @@ def test(self): return correct() def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=lambda: correct()) - ] + return [TestCase(dynamic_testing=lambda: correct())] diff --git a/tests/outcomes/dynamic_method/test_dynamic_method_wrong_answer_in_check_method/test.py b/tests/outcomes/dynamic_method/test_dynamic_method_wrong_answer_in_check_method/test.py index accbb631..3909e54a 100644 --- a/tests/outcomes/dynamic_method/test_dynamic_method_wrong_answer_in_check_method/test.py +++ b/tests/outcomes/dynamic_method/test_dynamic_method_wrong_answer_in_check_method/test.py @@ -15,9 +15,9 @@ class TestDynamicMethodUnexpectedErrorNoCheckMethod(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() - main.execute('main') + main.execute("main") main.execute("main2") return None diff --git a/tests/outcomes/dynamic_method/test_files/test.py b/tests/outcomes/dynamic_method/test_files/test.py index 869fc51b..639b737c 100644 --- a/tests/outcomes/dynamic_method/test_files/test.py +++ b/tests/outcomes/dynamic_method/test_files/test.py @@ -6,10 +6,10 @@ class TestFilesInDynamicTest(StageTest): - @dynamic_test(files={'123.txt': '12345'}) + @dynamic_test(files={"123.txt": "12345"}) def test(self): - if '123.txt' in os.listdir('.'): - if open('123.txt').read() == '12345': + if "123.txt" in os.listdir("."): + if open("123.txt").read() == "12345": return correct() return wrong('There should be a file named "123.txt" with content "12345"') diff --git a/tests/outcomes/dynamic_method/test_getting_output_while_program_in_background/test.py b/tests/outcomes/dynamic_method/test_getting_output_while_program_in_background/test.py index 6746d932..77c1632e 100644 --- a/tests/outcomes/dynamic_method/test_getting_output_while_program_in_background/test.py +++ b/tests/outcomes/dynamic_method/test_getting_output_while_program_in_background/test.py @@ -7,28 +7,28 @@ from hstest.testing.tested_program import TestedProgram -@unittest.skip('Background execution in python doesn\'t work') +@unittest.skip("Background execution in python doesn't work") class TestGettingOutputWhileProgramInBackground(StageTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start_in_background() out = main.get_output() - if out != '': - return wrong('') + if out != "": + return wrong("") sleep(0.15) out = main.get_output() if out != "Test\n": - return wrong('') + return wrong("") sleep(0.2) out = main.get_output() if out != "Test\nTest\n": - return wrong('') + return wrong("") main.stop() if not main.is_finished(): diff --git a/tests/outcomes/dynamic_method/test_right_sequence_of_tests/test.py b/tests/outcomes/dynamic_method/test_right_sequence_of_tests/test.py index 484039ed..a9ea0759 100644 --- a/tests/outcomes/dynamic_method/test_right_sequence_of_tests/test.py +++ b/tests/outcomes/dynamic_method/test_right_sequence_of_tests/test.py @@ -84,4 +84,4 @@ def test14(self): @dynamic_test def test15(self): - return wrong(f'x == {self.x}') + return wrong(f"x == {self.x}") diff --git a/tests/outcomes/dynamic_output/test_dynamic_output/main.py b/tests/outcomes/dynamic_output/test_dynamic_output/main.py index 351a129f..7c2c2db6 100644 --- a/tests/outcomes/dynamic_output/test_dynamic_output/main.py +++ b/tests/outcomes/dynamic_output/test_dynamic_output/main.py @@ -1,16 +1,16 @@ -print('1') -print('2') +print("1") +print("2") line_3 = input() -if line_3 != '3': - 0/0 -print('5') +if line_3 != "3": + 0 / 0 +print("5") line_4 = input() -if line_4 != '4': - 0/0 -print('6') +if line_4 != "4": + 0 / 0 +print("6") line_7 = input() -if line_7 != '7': - 0/0 +if line_7 != "7": + 0 / 0 line_8 = input() -if line_8 != '8': - 0/0 +if line_8 != "8": + 0 / 0 diff --git a/tests/outcomes/dynamic_output/test_dynamic_output/test.py b/tests/outcomes/dynamic_output/test_dynamic_output/test.py index 350a51e4..9973fd3d 100644 --- a/tests/outcomes/dynamic_output/test_dynamic_output/test.py +++ b/tests/outcomes/dynamic_output/test_dynamic_output/test.py @@ -8,19 +8,17 @@ class TestDynamicOutput(StageTest): def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[self.in1, self.in2]) - ] + return [TestCase(stdin=[self.in1, self.in2])] def in1(self, out): - if out != '1\n2\n': + if out != "1\n2\n": 0 / 0 - return '3\n4' + return "3\n4" def in2(self, out): - if out != '5\n6\n': + if out != "5\n6\n": 0 / 0 - return '7\n8\n' + return "7\n8\n" def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/dynamic_output/test_dynamic_output_with_input/main.py b/tests/outcomes/dynamic_output/test_dynamic_output_with_input/main.py index 81687294..23c78b4b 100644 --- a/tests/outcomes/dynamic_output/test_dynamic_output_with_input/main.py +++ b/tests/outcomes/dynamic_output/test_dynamic_output_with_input/main.py @@ -1,4 +1,4 @@ -input('Print x and y: ') +input("Print x and y: ") int(input()) -print('Another num:') +print("Another num:") int(input()) diff --git a/tests/outcomes/dynamic_output/test_dynamic_output_with_input/test.py b/tests/outcomes/dynamic_output/test_dynamic_output_with_input/test.py index 888d4243..251efa57 100644 --- a/tests/outcomes/dynamic_output/test_dynamic_output_with_input/test.py +++ b/tests/outcomes/dynamic_output/test_dynamic_output_with_input/test.py @@ -23,9 +23,7 @@ class TestDynamicOutputWithInput(UserErrorTest): not_contain = "Unexpected error" def generate(self) -> List[TestCase]: - return [ - TestCase(stdin="123 456\n678\n248") - ] + return [TestCase(stdin="123 456\n678\n248")] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/dynamic_output/test_dynamic_output_without_input/main.py b/tests/outcomes/dynamic_output/test_dynamic_output_without_input/main.py index d64ec65d..a851461e 100644 --- a/tests/outcomes/dynamic_output/test_dynamic_output_without_input/main.py +++ b/tests/outcomes/dynamic_output/test_dynamic_output_without_input/main.py @@ -1,3 +1,3 @@ -print('Print x and y: ', end='') -print('123 456') -print('Another num:') +print("Print x and y: ", end="") +print("123 456") +print("Another num:") diff --git a/tests/outcomes/dynamic_output/test_dynamic_output_without_input/test.py b/tests/outcomes/dynamic_output/test_dynamic_output_without_input/test.py index 695ec8d5..76b948a3 100644 --- a/tests/outcomes/dynamic_output/test_dynamic_output_without_input/test.py +++ b/tests/outcomes/dynamic_output/test_dynamic_output_without_input/test.py @@ -7,7 +7,7 @@ class TestDynamicOutputWithoutInput(UserErrorTest): contain = [ - 'Wrong answer in test #1', + "Wrong answer in test #1", """ Please find below the output of your program during this failed test. @@ -15,13 +15,11 @@ class TestDynamicOutputWithoutInput(UserErrorTest): Print x and y: 123 456 Another num: - """ # noqa: W293 + """, # noqa: W293 ] def generate(self) -> List[TestCase]: - return [ - TestCase(stdin="123 456\n678\n248") - ] + return [TestCase(stdin="123 456\n678\n248")] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/main.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/main.py index 005ed6ac..e3b7aea7 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/main.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/main.py @@ -1,2 +1,2 @@ -print('Hello World') +print("Hello World") print(1 / 0) diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/test.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/test.py index 91e51218..2108fe8a 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/test.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_1/test.py @@ -25,10 +25,10 @@ class FeedbackOnExceptionTest1(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(feedback_on_exception={ - ZeroDivisionError: 'Do not divide by zero!' - }) + TestCase( + feedback_on_exception={ZeroDivisionError: "Do not divide by zero!"} + ) ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_2/test.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_2/test.py index e7c4b4d2..3b6025c9 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_2/test.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_2/test.py @@ -6,7 +6,7 @@ class FeedbackOnExceptionTest2(UserErrorTest): - contain = ''' + contain = """ Exception in test #1 Attribute Error raised! @@ -14,15 +14,17 @@ class FeedbackOnExceptionTest2(UserErrorTest): Traceback (most recent call last): File "main.py", line 1, in raise AttributeError() - AttributeError''' # noqa: W293 + AttributeError""" # noqa: W293 def generate(self) -> List[TestCase]: return [ - TestCase(feedback_on_exception={ - ZeroDivisionError: 'Do not divide by zero!', - AttributeError: 'Attribute Error raised!' - }) + TestCase( + feedback_on_exception={ + ZeroDivisionError: "Do not divide by zero!", + AttributeError: "Attribute Error raised!", + } + ) ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_3/test.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_3/test.py index 6e9ccfa9..5338441d 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_3/test.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_3/test.py @@ -17,11 +17,13 @@ class FeedbackOnExceptionTest3(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(feedback_on_exception={ - ZeroDivisionError: 'Do not divide by zero!', - AttributeError: 'Attribute Error raised!' - }) + TestCase( + feedback_on_exception={ + ZeroDivisionError: "Do not divide by zero!", + AttributeError: "Attribute Error raised!", + } + ) ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_4/test.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_4/test.py index f407aca0..2e359505 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_4/test.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_4/test.py @@ -6,7 +6,7 @@ class FeedbackOnExceptionTest4(UserErrorTest): - contain = '''\ + contain = """\ Exception in test #1 Base ex raised @@ -14,16 +14,18 @@ class FeedbackOnExceptionTest4(UserErrorTest): Traceback (most recent call last): File "main.py", line 1, in raise Exception() - Exception''' # noqa: W293 + Exception""" # noqa: W293 def generate(self) -> List[TestCase]: return [ - TestCase(feedback_on_exception={ - ZeroDivisionError: 'Do not divide by zero!', - AttributeError: 'Attribute Error raised!', - Exception: 'Base ex raised' - }) + TestCase( + feedback_on_exception={ + ZeroDivisionError: "Do not divide by zero!", + AttributeError: "Attribute Error raised!", + Exception: "Base ex raised", + } + ) ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_module/test.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_module/test.py index d18cccb2..fcf858b1 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_module/test.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_module/test.py @@ -3,12 +3,13 @@ from hstest.check_result import CheckResult from hstest.test_case import TestCase from hstest.testing.execution.main_module_executor import MainModuleExecutor -from hstest.testing.runner.async_dynamic_testing_runner import AsyncDynamicTestingRunner +from hstest.testing.runner.async_dynamic_testing_runner import \ + AsyncDynamicTestingRunner from hstest.testing.unittest.user_error_test import UserErrorTest class FeedbackOnExceptionTest5(UserErrorTest): - contain = ''' + contain = """ Exception in test #1 Base ex raised @@ -16,17 +17,19 @@ class FeedbackOnExceptionTest5(UserErrorTest): Traceback (most recent call last): File "main.py", line 1, in raise ZeroDivisionError() - ZeroDivisionError''' # noqa: W293 + ZeroDivisionError""" # noqa: W293 runner = AsyncDynamicTestingRunner(MainModuleExecutor) def generate(self) -> List[TestCase]: return [ - TestCase(feedback_on_exception={ - AttributeError: 'Attribute Error raised!', - Exception: 'Base ex raised' - }) + TestCase( + feedback_on_exception={ + AttributeError: "Attribute Error raised!", + Exception: "Base ex raised", + } + ) ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_process/test.py b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_process/test.py index 355b569d..23ff846b 100644 --- a/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_process/test.py +++ b/tests/outcomes/feedback_on_exception/feedback_on_exception_test_5_process/test.py @@ -3,29 +3,32 @@ from hstest.check_result import CheckResult from hstest.test_case import TestCase from hstest.testing.execution.process.python_executor import PythonExecutor -from hstest.testing.runner.async_dynamic_testing_runner import AsyncDynamicTestingRunner +from hstest.testing.runner.async_dynamic_testing_runner import \ + AsyncDynamicTestingRunner from hstest.testing.runner.test_runner import TestRunner from hstest.testing.unittest.user_error_test import UserErrorTest class FeedbackOnExceptionTest5(UserErrorTest): - contain = ''' + contain = """ Exception in test #1 Traceback (most recent call last): File "main.py", line 1, in raise ZeroDivisionError() - ZeroDivisionError''' # noqa: W293 + ZeroDivisionError""" # noqa: W293 runner: TestRunner = AsyncDynamicTestingRunner(PythonExecutor) def generate(self) -> List[TestCase]: return [ - TestCase(feedback_on_exception={ - AttributeError: 'Attribute Error raised!', - Exception: 'Base ex raised' - }) + TestCase( + feedback_on_exception={ + AttributeError: "Attribute Error raised!", + Exception: "Base ex raised", + } + ) ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/dir1/main.py b/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/dir1/main.py index 12d36395..693eaecb 100644 --- a/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/dir1/main.py +++ b/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/dir1/main.py @@ -1 +1 @@ -print('Hello!') +print("Hello!") diff --git a/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/test.py b/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/test.py index 8e63f55f..c39cf659 100644 --- a/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/test.py +++ b/tests/outcomes/imports/not_fallback_on_not_found_executabe_file/test.py @@ -14,11 +14,9 @@ class FindModuleNoInfoAnalyzeImports(UserErrorTest): """ # noqa: W291 def test1(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() - return wrong('') + return wrong("") def generate(self) -> List[TestCase]: - return [ - TestCase(dynamic_testing=self.test1) - ] + return [TestCase(dynamic_testing=self.test1)] diff --git a/tests/outcomes/imports/test_import_absolute/random_module/main.py b/tests/outcomes/imports/test_import_absolute/random_module/main.py index a5bc3e01..94c608e1 100644 --- a/tests/outcomes/imports/test_import_absolute/random_module/main.py +++ b/tests/outcomes/imports/test_import_absolute/random_module/main.py @@ -1,2 +1,3 @@ from main2 import x + print(x) diff --git a/tests/outcomes/imports/test_import_absolute/test.py b/tests/outcomes/imports/test_import_absolute/test.py index e92a9090..926ad02c 100644 --- a/tests/outcomes/imports/test_import_absolute/test.py +++ b/tests/outcomes/imports/test_import_absolute/test.py @@ -6,10 +6,10 @@ class TestImportAbsolute(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '101\n', '') + return CheckResult(reply == "101\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_2/random_module/main.py b/tests/outcomes/imports/test_import_absolute_2/random_module/main.py index 65894397..79b79390 100644 --- a/tests/outcomes/imports/test_import_absolute_2/random_module/main.py +++ b/tests/outcomes/imports/test_import_absolute_2/random_module/main.py @@ -1,2 +1,3 @@ import main2 + print(main2.x) diff --git a/tests/outcomes/imports/test_import_absolute_2/test.py b/tests/outcomes/imports/test_import_absolute_2/test.py index 138d8007..f609ab95 100644 --- a/tests/outcomes/imports/test_import_absolute_2/test.py +++ b/tests/outcomes/imports/test_import_absolute_2/test.py @@ -6,10 +6,10 @@ class TestImportAbsolute2(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '102\n', '') + return CheckResult(reply == "102\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error/main.py b/tests/outcomes/imports/test_import_absolute_error/main.py index a5bc3e01..94c608e1 100644 --- a/tests/outcomes/imports/test_import_absolute_error/main.py +++ b/tests/outcomes/imports/test_import_absolute_error/main.py @@ -1,2 +1,3 @@ from main2 import x + print(x) diff --git a/tests/outcomes/imports/test_import_absolute_error/test.py b/tests/outcomes/imports/test_import_absolute_error/test.py index f1d466b4..77cc1e16 100644 --- a/tests/outcomes/imports/test_import_absolute_error/test.py +++ b/tests/outcomes/imports/test_import_absolute_error/test.py @@ -11,4 +11,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '103\n', '') + return CheckResult(reply == "103\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_2/main.py b/tests/outcomes/imports/test_import_absolute_error_2/main.py index 65894397..79b79390 100644 --- a/tests/outcomes/imports/test_import_absolute_error_2/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_2/main.py @@ -1,2 +1,3 @@ import main2 + print(main2.x) diff --git a/tests/outcomes/imports/test_import_absolute_error_2/test.py b/tests/outcomes/imports/test_import_absolute_error_2/test.py index 41d58673..8fe3ecb2 100644 --- a/tests/outcomes/imports/test_import_absolute_error_2/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_2/test.py @@ -11,4 +11,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '104\n', '') + return CheckResult(reply == "104\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_circular/main.py b/tests/outcomes/imports/test_import_absolute_error_circular/main.py index 65894397..79b79390 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular/main.py @@ -1,2 +1,3 @@ import main2 + print(main2.x) diff --git a/tests/outcomes/imports/test_import_absolute_error_circular/main2.py b/tests/outcomes/imports/test_import_absolute_error_circular/main2.py index 33f227b6..0d807d37 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular/main2.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular/main2.py @@ -1,2 +1,2 @@ -import main + x = 1040 diff --git a/tests/outcomes/imports/test_import_absolute_error_circular/test.py b/tests/outcomes/imports/test_import_absolute_error_circular/test.py index a8fe1ee9..04f3285a 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular/test.py @@ -18,10 +18,10 @@ class TestImportAbsoluteErrorCircular(UserErrorTest): print(main2.x) """ - source = 'main' + source = "main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '1040\n', '') + return CheckResult(reply == "1040\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_2/main.py b/tests/outcomes/imports/test_import_absolute_error_circular_2/main.py index fca25034..c66b96bf 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_2/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_2/main.py @@ -1,5 +1,6 @@ import main2 + print(main2.x) -if __name__ == '__main__': +if __name__ == "__main__": print() diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_2/main2.py b/tests/outcomes/imports/test_import_absolute_error_circular_2/main2.py index 6b3a1ee2..7371ca25 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_2/main2.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_2/main2.py @@ -1,2 +1,2 @@ -import main + x = 105 diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_2/test.py b/tests/outcomes/imports/test_import_absolute_error_circular_2/test.py index 811cea1f..19638c5c 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_2/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_2/test.py @@ -22,4 +22,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '105\n', '') + return CheckResult(reply == "105\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_3/main.py b/tests/outcomes/imports/test_import_absolute_error_circular_3/main.py index 97492aa8..ad083ff9 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_3/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_3/main.py @@ -1,4 +1,4 @@ import main2 -if __name__ == '__main__': +if __name__ == "__main__": print(main2.x) diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_3/main2.py b/tests/outcomes/imports/test_import_absolute_error_circular_3/main2.py index f56d1473..b3a1565f 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_3/main2.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_3/main2.py @@ -1,2 +1,2 @@ -import main + x = 106 diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_3/test.py b/tests/outcomes/imports/test_import_absolute_error_circular_3/test.py index cd606c47..dffc1ee2 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_3/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_3/test.py @@ -11,4 +11,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '106\n', '') + return CheckResult(reply == "106\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_4/main.py b/tests/outcomes/imports/test_import_absolute_error_circular_4/main.py index 65894397..79b79390 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_4/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_4/main.py @@ -1,2 +1,3 @@ import main2 + print(main2.x) diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_4/main2.py b/tests/outcomes/imports/test_import_absolute_error_circular_4/main2.py index 3f75e462..27c477d7 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_4/main2.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_4/main2.py @@ -1,2 +1,2 @@ -import main + x = 107 diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_4/test.py b/tests/outcomes/imports/test_import_absolute_error_circular_4/test.py index 3c85993f..86e4d2e9 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_4/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_4/test.py @@ -17,4 +17,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '107\n', '') + return CheckResult(reply == "107\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_5/main.py b/tests/outcomes/imports/test_import_absolute_error_circular_5/main.py index fca25034..c66b96bf 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_5/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_5/main.py @@ -1,5 +1,6 @@ import main2 + print(main2.x) -if __name__ == '__main__': +if __name__ == "__main__": print() diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_5/main2.py b/tests/outcomes/imports/test_import_absolute_error_circular_5/main2.py index b686d328..4fedd103 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_5/main2.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_5/main2.py @@ -1,2 +1,2 @@ -import main + x = 108 diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_5/test.py b/tests/outcomes/imports/test_import_absolute_error_circular_5/test.py index 848a87df..009d9275 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_5/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_5/test.py @@ -22,4 +22,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '108\n', '') + return CheckResult(reply == "108\n", "") diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_6/main.py b/tests/outcomes/imports/test_import_absolute_error_circular_6/main.py index 97492aa8..ad083ff9 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_6/main.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_6/main.py @@ -1,4 +1,4 @@ import main2 -if __name__ == '__main__': +if __name__ == "__main__": print(main2.x) diff --git a/tests/outcomes/imports/test_import_absolute_error_circular_6/test.py b/tests/outcomes/imports/test_import_absolute_error_circular_6/test.py index 80cd87cf..138aa279 100644 --- a/tests/outcomes/imports/test_import_absolute_error_circular_6/test.py +++ b/tests/outcomes/imports/test_import_absolute_error_circular_6/test.py @@ -11,4 +11,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '109\n', '') + return CheckResult(reply == "109\n", "") diff --git a/tests/outcomes/imports/test_import_package/random_module/main.py b/tests/outcomes/imports/test_import_package/random_module/main.py index 7d740d42..ee810aee 100644 --- a/tests/outcomes/imports/test_import_package/random_module/main.py +++ b/tests/outcomes/imports/test_import_package/random_module/main.py @@ -1,2 +1,3 @@ from in1.in2.main2 import x + print(x) diff --git a/tests/outcomes/imports/test_import_package/test.py b/tests/outcomes/imports/test_import_package/test.py index dce0b07f..57528b9f 100644 --- a/tests/outcomes/imports/test_import_package/test.py +++ b/tests/outcomes/imports/test_import_package/test.py @@ -6,10 +6,10 @@ class TestImportPackage(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '1011\n', '') + return CheckResult(reply == "1011\n", "") diff --git a/tests/outcomes/imports/test_import_package_2/random_module/main.py b/tests/outcomes/imports/test_import_package_2/random_module/main.py index 2cc69f92..67a1f109 100644 --- a/tests/outcomes/imports/test_import_package_2/random_module/main.py +++ b/tests/outcomes/imports/test_import_package_2/random_module/main.py @@ -1,2 +1,3 @@ from .in1.in2.main2 import x + print(x) diff --git a/tests/outcomes/imports/test_import_package_2/test.py b/tests/outcomes/imports/test_import_package_2/test.py index 3354fba7..5f076c00 100644 --- a/tests/outcomes/imports/test_import_package_2/test.py +++ b/tests/outcomes/imports/test_import_package_2/test.py @@ -6,12 +6,12 @@ from hstest.test_case import TestCase -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportPackage2(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '10\n', '') + return CheckResult(reply == "10\n", "") diff --git a/tests/outcomes/imports/test_import_package_3/random_module/main.py b/tests/outcomes/imports/test_import_package_3/random_module/main.py index 6294ae80..fecdf909 100644 --- a/tests/outcomes/imports/test_import_package_3/random_module/main.py +++ b/tests/outcomes/imports/test_import_package_3/random_module/main.py @@ -1,3 +1,4 @@ -import in1.in2.main2 import in1.file +import in1.in2.main2 + print(in1.in2.main2.x + in1.file.y) diff --git a/tests/outcomes/imports/test_import_package_3/test.py b/tests/outcomes/imports/test_import_package_3/test.py index 214f6075..4fb64e06 100644 --- a/tests/outcomes/imports/test_import_package_3/test.py +++ b/tests/outcomes/imports/test_import_package_3/test.py @@ -6,10 +6,10 @@ class TestImportPackage3(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '3025\n', '') + return CheckResult(reply == "3025\n", "") diff --git a/tests/outcomes/imports/test_import_package_4/random_module/main.py b/tests/outcomes/imports/test_import_package_4/random_module/main.py index c24b37fb..59dbfd4c 100644 --- a/tests/outcomes/imports/test_import_package_4/random_module/main.py +++ b/tests/outcomes/imports/test_import_package_4/random_module/main.py @@ -1,3 +1,4 @@ -from .in1.in2.main2 import x from .in1.file import y +from .in1.in2.main2 import x + print(x + y) diff --git a/tests/outcomes/imports/test_import_package_4/test.py b/tests/outcomes/imports/test_import_package_4/test.py index cd8dbd96..15616491 100644 --- a/tests/outcomes/imports/test_import_package_4/test.py +++ b/tests/outcomes/imports/test_import_package_4/test.py @@ -6,12 +6,12 @@ from hstest.test_case import TestCase -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportPackage4(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '3029\n', '') + return CheckResult(reply == "3029\n", "") diff --git a/tests/outcomes/imports/test_import_package_5/random_module/main.py b/tests/outcomes/imports/test_import_package_5/random_module/main.py index 01d7ca23..a0f7f009 100644 --- a/tests/outcomes/imports/test_import_package_5/random_module/main.py +++ b/tests/outcomes/imports/test_import_package_5/random_module/main.py @@ -1,3 +1,4 @@ -import in1.in2.main2 as m import in1.file as f +import in1.in2.main2 as m + print(m.x + f.y) diff --git a/tests/outcomes/imports/test_import_package_5/test.py b/tests/outcomes/imports/test_import_package_5/test.py index 4c0d1412..dbb58b82 100644 --- a/tests/outcomes/imports/test_import_package_5/test.py +++ b/tests/outcomes/imports/test_import_package_5/test.py @@ -6,10 +6,10 @@ class TestImportPackage5(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '3061\n', '') + return CheckResult(reply == "3061\n", "") diff --git a/tests/outcomes/imports/test_import_package_6/random_module/main.py b/tests/outcomes/imports/test_import_package_6/random_module/main.py index 82efb027..81ad0201 100644 --- a/tests/outcomes/imports/test_import_package_6/random_module/main.py +++ b/tests/outcomes/imports/test_import_package_6/random_module/main.py @@ -1,3 +1,4 @@ -from in1.in2 import main2 from in1 import file +from in1.in2 import main2 + print(main2.x + file.y) diff --git a/tests/outcomes/imports/test_import_package_6/test.py b/tests/outcomes/imports/test_import_package_6/test.py index 7c2b3352..22f3bfa5 100644 --- a/tests/outcomes/imports/test_import_package_6/test.py +++ b/tests/outcomes/imports/test_import_package_6/test.py @@ -6,10 +6,10 @@ class TestImportPackage6(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '3065\n', '') + return CheckResult(reply == "3065\n", "") diff --git a/tests/outcomes/imports/test_import_package_7/random_module/main.py b/tests/outcomes/imports/test_import_package_7/random_module/main.py index a85c8df6..ba674559 100644 --- a/tests/outcomes/imports/test_import_package_7/random_module/main.py +++ b/tests/outcomes/imports/test_import_package_7/random_module/main.py @@ -1,3 +1,4 @@ -from .in1.in2 import main2 from .in1 import file +from .in1.in2 import main2 + print(main2.x + file.y) diff --git a/tests/outcomes/imports/test_import_package_7/test.py b/tests/outcomes/imports/test_import_package_7/test.py index 10dfd95f..21576f19 100644 --- a/tests/outcomes/imports/test_import_package_7/test.py +++ b/tests/outcomes/imports/test_import_package_7/test.py @@ -6,12 +6,12 @@ from hstest.test_case import TestCase -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportPackage7(StageTest): - source = 'random_module.main' + source = "random_module.main" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '3067\n', '') + return CheckResult(reply == "3067\n", "") diff --git a/tests/outcomes/imports/test_import_relative/main.py b/tests/outcomes/imports/test_import_relative/main.py index 21d00271..3830ed5b 100644 --- a/tests/outcomes/imports/test_import_relative/main.py +++ b/tests/outcomes/imports/test_import_relative/main.py @@ -1,2 +1,3 @@ from .main2 import x + print(x) diff --git a/tests/outcomes/imports/test_import_relative/test.py b/tests/outcomes/imports/test_import_relative/test.py index 718c987f..ecd8424f 100644 --- a/tests/outcomes/imports/test_import_relative/test.py +++ b/tests/outcomes/imports/test_import_relative/test.py @@ -6,11 +6,11 @@ from hstest.test_case import TestCase -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportRelative(StageTest): def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '1035\n', '') + return CheckResult(reply == "1035\n", "") diff --git a/tests/outcomes/imports/test_import_relative_error/main.py b/tests/outcomes/imports/test_import_relative_error/main.py index 7a301da4..11cfb7d6 100644 --- a/tests/outcomes/imports/test_import_relative_error/main.py +++ b/tests/outcomes/imports/test_import_relative_error/main.py @@ -1,2 +1,3 @@ from .main22 import x + print(x) diff --git a/tests/outcomes/imports/test_import_relative_error/test.py b/tests/outcomes/imports/test_import_relative_error/test.py index 4b524857..44771845 100644 --- a/tests/outcomes/imports/test_import_relative_error/test.py +++ b/tests/outcomes/imports/test_import_relative_error/test.py @@ -6,7 +6,7 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportRelativeError(UserErrorTest): contain = """ Error in test #1 @@ -21,4 +21,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '1036\n', '') + return CheckResult(reply == "1036\n", "") diff --git a/tests/outcomes/imports/test_import_relative_error_2/main.py b/tests/outcomes/imports/test_import_relative_error_2/main.py index 98b77719..d84370c6 100644 --- a/tests/outcomes/imports/test_import_relative_error_2/main.py +++ b/tests/outcomes/imports/test_import_relative_error_2/main.py @@ -1,2 +1,2 @@ -from .main2 import y + print(x) diff --git a/tests/outcomes/imports/test_import_relative_error_2/test.py b/tests/outcomes/imports/test_import_relative_error_2/test.py index 965ab378..d12ef1da 100644 --- a/tests/outcomes/imports/test_import_relative_error_2/test.py +++ b/tests/outcomes/imports/test_import_relative_error_2/test.py @@ -6,7 +6,7 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportRelativeError2(UserErrorTest): contain = """ Error in test #1 @@ -21,4 +21,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '1037\n', '') + return CheckResult(reply == "1037\n", "") diff --git a/tests/outcomes/imports/test_import_relative_error_cilcullar/main.py b/tests/outcomes/imports/test_import_relative_error_cilcullar/main.py index a6c0b14b..ceb58d2b 100644 --- a/tests/outcomes/imports/test_import_relative_error_cilcullar/main.py +++ b/tests/outcomes/imports/test_import_relative_error_cilcullar/main.py @@ -1,3 +1,4 @@ from .main2 import x + y = 5 print(x) diff --git a/tests/outcomes/imports/test_import_relative_error_cilcullar/main2.py b/tests/outcomes/imports/test_import_relative_error_cilcullar/main2.py index 99b4e3ca..0c378b71 100644 --- a/tests/outcomes/imports/test_import_relative_error_cilcullar/main2.py +++ b/tests/outcomes/imports/test_import_relative_error_cilcullar/main2.py @@ -1,3 +1,4 @@ from .main import y + x = 1038 print(y) diff --git a/tests/outcomes/imports/test_import_relative_error_cilcullar/test.py b/tests/outcomes/imports/test_import_relative_error_cilcullar/test.py index d26be850..7cfb9fca 100644 --- a/tests/outcomes/imports/test_import_relative_error_cilcullar/test.py +++ b/tests/outcomes/imports/test_import_relative_error_cilcullar/test.py @@ -6,7 +6,7 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('Relative imports doesn\'t work') +@unittest.skip("Relative imports doesn't work") class TestImportRelativeErrorCircular(UserErrorTest): contain = """ Error in test #1 @@ -25,4 +25,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == '1038\n', '') + return CheckResult(reply == "1038\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source/test.py index f490ad3b..40c47103 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source/test.py @@ -1,6 +1,6 @@ from typing import Any, List -from hstest import CheckResult, correct, TestCase +from hstest import CheckResult, TestCase, correct from hstest.testing.unittest.user_error_test import UserErrorTest diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/test.py index 4f656692..cdda278a 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_2/test.py @@ -4,10 +4,10 @@ class TestImportRelativeError2(StageTest): - source = 'main1' + source = "main1" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == 'main1\n', '') + return CheckResult(reply == "main1\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/test.py index 8815ef70..c1890bc3 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_3/test.py @@ -4,10 +4,10 @@ class TestImportRelativeError2(StageTest): - source = 'main2' + source = "main2" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == 'main2\n', '') + return CheckResult(reply == "main2\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/test.py index 4d5a51cd..a018e5f5 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_4/test.py @@ -1,4 +1,4 @@ -from hstest import correct, dynamic_test, TestedProgram +from hstest import TestedProgram, correct, dynamic_test from hstest.testing.unittest.user_error_test import UserErrorTest diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/test.py index 17f9761a..5b1b1634 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_5/test.py @@ -1,8 +1,8 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class TestImportRelativeError2(StageTest): @dynamic_test def test(self): - pr = TestedProgram('main1') - return CheckResult(pr.start() == 'main1\n', '') + pr = TestedProgram("main1") + return CheckResult(pr.start() == "main1\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/test.py index ea8a73f5..596e51a9 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_6/test.py @@ -1,8 +1,8 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class TestImportRelativeError2(StageTest): @dynamic_test def test(self): - pr = TestedProgram('main2') - return CheckResult(pr.start() == 'main2\n', '') + pr = TestedProgram("main2") + return CheckResult(pr.start() == "main2\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/test.py index fcc96e17..0224e432 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_7/test.py @@ -1,10 +1,10 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class TestImportRelativeError2(StageTest): - source = 'main1' + source = "main1" @dynamic_test def test(self): pr = TestedProgram() - return CheckResult(pr.start() == 'main1\n', '') + return CheckResult(pr.start() == "main1\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/test.py index 41189a42..9d40f104 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_8/test.py @@ -1,10 +1,10 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class TestImportRelativeError2(StageTest): - source = 'main2' + source = "main2" @dynamic_test def test(self): pr = TestedProgram() - return CheckResult(pr.start() == 'main2\n', '') + return CheckResult(pr.start() == "main2\n", "") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main1.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main1.py index eaa71ec2..1405a7ec 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main1.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main1.py @@ -1 +1 @@ -print('main1') +print("main1") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main2.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main2.py index 48a8aacb..d7f1daaa 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main2.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/main2.py @@ -1 +1 @@ -print('main2') +print("main2") diff --git a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/test.py b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/test.py index e5e95047..5fd4a83b 100644 --- a/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/test.py +++ b/tests/outcomes/imports/test_two_files_suits_but_we_have_source_9/test.py @@ -1,4 +1,4 @@ -from hstest import CheckResult, dynamic_test, TestedProgram +from hstest import CheckResult, TestedProgram, dynamic_test from hstest.testing.unittest.user_error_test import UserErrorTest @@ -10,9 +10,9 @@ class TestImportRelativeError2(UserErrorTest): Write "if __name__ == '__main__'" in one of them to mark it as an entry point. """ - source = 'main' + source = "main" @dynamic_test def test(self): - pr = TestedProgram('') - return CheckResult(pr.start() == 'main2\n', '') + pr = TestedProgram("") + return CheckResult(pr.start() == "main2\n", "") diff --git a/tests/outcomes/imports/user_main_file_not_exists/test.py b/tests/outcomes/imports/user_main_file_not_exists/test.py index 58ffafde..47d68873 100644 --- a/tests/outcomes/imports/user_main_file_not_exists/test.py +++ b/tests/outcomes/imports/user_main_file_not_exists/test.py @@ -17,4 +17,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/imports/user_main_file_not_exists_but_exists_other/test.py b/tests/outcomes/imports/user_main_file_not_exists_but_exists_other/test.py index 97305066..131761c3 100644 --- a/tests/outcomes/imports/user_main_file_not_exists_but_exists_other/test.py +++ b/tests/outcomes/imports/user_main_file_not_exists_but_exists_other/test.py @@ -13,10 +13,10 @@ class UnexpectedErrorUserMainFileNotExistsButExistsOther(UserErrorTest): Are your project files located at """ - source = 'bad_file' + source = "bad_file" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/imports/user_module_not_exists/test.py b/tests/outcomes/imports/user_module_not_exists/test.py index 1481cd68..726048c9 100644 --- a/tests/outcomes/imports/user_module_not_exists/test.py +++ b/tests/outcomes/imports/user_module_not_exists/test.py @@ -13,10 +13,10 @@ class UnexpectedErrorUserModuleNotExists(UserErrorTest): Are your project files located at """ - source = 'tests.bad_module' + source = "tests.bad_module" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/imports/user_module_not_exists_but_exists_other/random_module/main.py b/tests/outcomes/imports/user_module_not_exists_but_exists_other/random_module/main.py index 7bb276c8..47d93078 100644 --- a/tests/outcomes/imports/user_module_not_exists_but_exists_other/random_module/main.py +++ b/tests/outcomes/imports/user_module_not_exists_but_exists_other/random_module/main.py @@ -1 +1 @@ -print('2050') +print("2050") diff --git a/tests/outcomes/imports/user_module_not_exists_but_exists_other/test.py b/tests/outcomes/imports/user_module_not_exists_but_exists_other/test.py index 8b3d2042..aa55b830 100644 --- a/tests/outcomes/imports/user_module_not_exists_but_exists_other/test.py +++ b/tests/outcomes/imports/user_module_not_exists_but_exists_other/test.py @@ -13,10 +13,10 @@ class UnexpectedErrorUserModuleNotExistsButExistsOther(UserErrorTest): Are your project files located at """ - source = 'tests.bad_module' + source = "tests.bad_module" def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_char/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_char/test.py index 992868d2..daf89b56 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_char/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_char/test.py @@ -15,7 +15,7 @@ class InfiniteLoopTestChar(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_input_request/main.py b/tests/outcomes/infinite_loop/infinite_loop_test_input_request/main.py index 3a6e38f9..af8bdfc4 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_input_request/main.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_input_request/main.py @@ -1,4 +1,3 @@ - while True: print("Long Line Long Line Long Line") try: diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_input_request/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_input_request/test.py index a001bf4f..3edfe14d 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_input_request/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_input_request/test.py @@ -20,7 +20,7 @@ class InfiniteLoopTestInputRequest(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() main.stop_input() sleep(0.005) diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_1/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_1/test.py index 83afff1f..744b5e2e 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_1/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_1/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine1(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_10/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_10/test.py index cbba0a8a..f3bd9c71 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_10/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_10/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine10(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_11/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_11/test.py index 9c5cad1e..a358d160 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_11/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_11/test.py @@ -15,7 +15,7 @@ class InfiniteLoopTestLine11(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_2/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_2/test.py index 2439402c..a1d05edd 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_2/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_2/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine2(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_3/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_3/test.py index 2e3ce4e9..7c113ad3 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_3/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_3/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine3(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_4/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_4/test.py index 5947e7ba..a9a0d90a 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_4/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_4/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine4(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_5/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_5/test.py index 584f5f16..f10ba966 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_5/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_5/test.py @@ -13,6 +13,6 @@ class InfiniteLoopTestLine5(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_6/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_6/test.py index 11cb10fc..5369a5cb 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_6/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_6/test.py @@ -13,6 +13,6 @@ class InfiniteLoopTestLine6(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_7/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_7/test.py index f2b31813..9cd0e3fc 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_7/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_7/test.py @@ -13,6 +13,6 @@ class InfiniteLoopTestLine7(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_8/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_8/test.py index 5c8592d1..ee9dc9b3 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_8/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_8/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine8(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_line_9/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_line_9/test.py index f7f52e52..bab53217 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_line_9/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_line_9/test.py @@ -14,6 +14,6 @@ class InfiniteLoopTestLine9(UserErrorTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/infinite_loop/infinite_loop_test_not_working/test.py b/tests/outcomes/infinite_loop/infinite_loop_test_not_working/test.py index ad595f0f..1e356662 100644 --- a/tests/outcomes/infinite_loop/infinite_loop_test_not_working/test.py +++ b/tests/outcomes/infinite_loop/infinite_loop_test_not_working/test.py @@ -8,7 +8,7 @@ class InfiniteLoopTestNotWorking(StageTest): @dynamic_test def test(self): - main = TestedProgram('main') + main = TestedProgram("main") main.start() return correct() diff --git a/tests/outcomes/input_handle/exception_while_reading/test.py b/tests/outcomes/input_handle/exception_while_reading/test.py index a6ebafba..405b9855 100644 --- a/tests/outcomes/input_handle/exception_while_reading/test.py +++ b/tests/outcomes/input_handle/exception_while_reading/test.py @@ -7,20 +7,17 @@ class ExceptionWhileReading(UserErrorTest): contain = [ - 'Exception in test #2', - 'Traceback (most recent call last):', - ' print(get_line())', - ' return get_num()', - ' return get()', - ' return int(input())', - 'ValueError: invalid literal for int() with base 10: \'strange\'' + "Exception in test #2", + "Traceback (most recent call last):", + " print(get_line())", + " return get_num()", + " return get()", + " return int(input())", + "ValueError: invalid literal for int() with base 10: 'strange'", ] def generate(self) -> List[TestCase]: - return [ - TestCase(stdin='1'), - TestCase(stdin='strange') - ] + return [TestCase(stdin="1"), TestCase(stdin="strange")] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/input_handle/exception_while_reading_2/test.py b/tests/outcomes/input_handle/exception_while_reading_2/test.py index a0a5ae77..0f29cdeb 100644 --- a/tests/outcomes/input_handle/exception_while_reading_2/test.py +++ b/tests/outcomes/input_handle/exception_while_reading_2/test.py @@ -22,9 +22,7 @@ class ExceptionWhileReading2(UserErrorTest): line2""" # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase(stdin='line1\nline2') - ] + return [TestCase(stdin="line1\nline2")] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/input_handle/success_but_not_used_input_1/test.py b/tests/outcomes/input_handle/success_but_not_used_input_1/test.py index 774f9d71..1f421b93 100644 --- a/tests/outcomes/input_handle/success_but_not_used_input_1/test.py +++ b/tests/outcomes/input_handle/success_but_not_used_input_1/test.py @@ -9,9 +9,9 @@ class SuccessButNotUsedInput1(StageTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin='1\nnotnum\n', attach='1\n'), - TestCase(stdin='2\nnotnum\n', attach='2\nnotnum\n'), + TestCase(stdin="1\nnotnum\n", attach="1\n"), + TestCase(stdin="2\nnotnum\n", attach="2\nnotnum\n"), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/input_handle/success_but_not_used_input_2/main.py b/tests/outcomes/input_handle/success_but_not_used_input_2/main.py index ea232efc..8015f79b 100644 --- a/tests/outcomes/input_handle/success_but_not_used_input_2/main.py +++ b/tests/outcomes/input_handle/success_but_not_used_input_2/main.py @@ -1,3 +1,3 @@ -print('HELLO') +print("HELLO") print(input()) print(input()) diff --git a/tests/outcomes/input_handle/success_but_not_used_input_2/test.py b/tests/outcomes/input_handle/success_but_not_used_input_2/test.py index 810e8331..dae0d6cc 100644 --- a/tests/outcomes/input_handle/success_but_not_used_input_2/test.py +++ b/tests/outcomes/input_handle/success_but_not_used_input_2/test.py @@ -8,14 +8,12 @@ class SuccessButNotUsedInput2(StageTest): def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[self.add_input], attach='NO') - ] + return [TestCase(stdin=[self.add_input], attach="NO")] def add_input(self, out: str): - if out == 'HELLO\n': + if out == "HELLO\n": return CheckResult.correct() - return '' + return "" def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/main.py b/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/main.py index e0df1b89..61d78bed 100644 --- a/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/main.py +++ b/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/main.py @@ -1,6 +1,6 @@ -print('1') -print('2') +print("1") +print("2") line_3 = input() -print('5') +print("5") line_4 = input() -print('6') +print("6") diff --git a/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/test.py b/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/test.py index 19c2c48a..d47e34e4 100644 --- a/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/test.py +++ b/tests/outcomes/input_handle/test_not_run_not_needed_input_funcs/test.py @@ -8,9 +8,7 @@ class TestNotRunNotNeededInputFuncs(StageTest): def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[lambda x: '3\n4', lambda x: 0 / 0]) - ] + return [TestCase(stdin=[lambda x: "3\n4", lambda x: 0 / 0])] def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/input_handle/test_out_of_input_1/test.py b/tests/outcomes/input_handle/test_out_of_input_1/test.py index 0b71a808..b0f1f5bd 100644 --- a/tests/outcomes/input_handle/test_out_of_input_1/test.py +++ b/tests/outcomes/input_handle/test_out_of_input_1/test.py @@ -29,11 +29,15 @@ class TestOutOfInput1(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[lambda x: '1', - lambda x: '2', - lambda x: '3', - lambda x: '4', - lambda x: '5']) + TestCase( + stdin=[ + lambda x: "1", + lambda x: "2", + lambda x: "3", + lambda x: "4", + lambda x: "5", + ] + ) ] def check(self, reply: str, attach: Any) -> CheckResult: diff --git a/tests/outcomes/input_handle/test_out_of_input_2/test.py b/tests/outcomes/input_handle/test_out_of_input_2/test.py index dbc18a55..a9962b8a 100644 --- a/tests/outcomes/input_handle/test_out_of_input_2/test.py +++ b/tests/outcomes/input_handle/test_out_of_input_2/test.py @@ -30,10 +30,9 @@ class TestOutOfInput2(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[lambda x: '1', - lambda x: '2', - lambda x: '3', - (2, lambda x: '4')]) + TestCase( + stdin=[lambda x: "1", lambda x: "2", lambda x: "3", (2, lambda x: "4")] + ) ] def check(self, reply: str, attach: Any) -> CheckResult: diff --git a/tests/outcomes/input_handle/test_out_of_input_3/test.py b/tests/outcomes/input_handle/test_out_of_input_3/test.py index f689d561..5ad94252 100644 --- a/tests/outcomes/input_handle/test_out_of_input_3/test.py +++ b/tests/outcomes/input_handle/test_out_of_input_3/test.py @@ -13,11 +13,7 @@ class TestOutOfInput3(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[lambda x: '1', - (3, lambda x: '2'), - lambda x: '4']) - ] + return [TestCase(stdin=[lambda x: "1", (3, lambda x: "2"), lambda x: "4"])] def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/input_handle/test_out_of_input_4/test.py b/tests/outcomes/input_handle/test_out_of_input_4/test.py index 88d6656f..330f1aac 100644 --- a/tests/outcomes/input_handle/test_out_of_input_4/test.py +++ b/tests/outcomes/input_handle/test_out_of_input_4/test.py @@ -13,10 +13,7 @@ class TestOutOfInput4(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[(2, lambda x: '1\n2'), - lambda x: '2']) - ] + return [TestCase(stdin=[(2, lambda x: "1\n2"), lambda x: "2"])] def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/lib/exception_in_user_code/test.py b/tests/outcomes/lib/exception_in_user_code/test.py index d85427cc..27292658 100644 --- a/tests/outcomes/lib/exception_in_user_code/test.py +++ b/tests/outcomes/lib/exception_in_user_code/test.py @@ -7,18 +7,18 @@ class ExceptionInUserCodeTest(UserErrorTest): contain = [ - 'Exception in test #1', - 'Traceback (most recent call last):', + "Exception in test #1", + "Traceback (most recent call last):", r' File "main.py", line 2', - ' print(0 / 0)', - 'ZeroDivisionError: division by zero' + " print(0 / 0)", + "ZeroDivisionError: division by zero", ] def generate(self) -> List[TestCase]: return [ - TestCase(stdin='2\n4', attach='6\n'), - TestCase(stdin='1\n3', attach='4\n'), + TestCase(stdin="2\n4", attach="6\n"), + TestCase(stdin="1\n3", attach="4\n"), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/exception_in_user_code_2/test.py b/tests/outcomes/lib/exception_in_user_code_2/test.py index b7789d55..8cd5ee2c 100644 --- a/tests/outcomes/lib/exception_in_user_code_2/test.py +++ b/tests/outcomes/lib/exception_in_user_code_2/test.py @@ -25,9 +25,9 @@ class ExceptionInUserCodeTest(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin='2\n4', attach='6\n'), - TestCase(stdin='1\n3', attach='4\n'), + TestCase(stdin="2\n4", attach="6\n"), + TestCase(stdin="1\n3", attach="4\n"), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/exception_in_user_code_3/module/main.py b/tests/outcomes/lib/exception_in_user_code_3/module/main.py index e30b1841..2119a962 100644 --- a/tests/outcomes/lib/exception_in_user_code_3/module/main.py +++ b/tests/outcomes/lib/exception_in_user_code_3/module/main.py @@ -1,2 +1,5 @@ -print(""" -Coffee is ready!""", raise_error_here) +print( + """ +Coffee is ready!""", + raise_error_here, +) diff --git a/tests/outcomes/lib/order/test_order_complex/test.py b/tests/outcomes/lib/order/test_order_complex/test.py index 61ddfdf9..02f83c66 100644 --- a/tests/outcomes/lib/order/test_order_complex/test.py +++ b/tests/outcomes/lib/order/test_order_complex/test.py @@ -12,27 +12,27 @@ class TestOrderComplex(StageTest): @dynamic_test(order=5) def test4(self): self.x += 1 - return CheckResult(self.x == 8, 'test3') + return CheckResult(self.x == 8, "test3") @dynamic_test(order=-5) def test0(self): self.x += 1 - return CheckResult(self.x == 4, 'test0') + return CheckResult(self.x == 4, "test0") @dynamic_test(order=-1) def test1(self): self.x += 1 - return CheckResult(self.x == 5, 'test1') + return CheckResult(self.x == 5, "test1") @dynamic_test() def test2(self): self.x += 1 - return CheckResult(self.x == 6, 'test2') + return CheckResult(self.x == 6, "test2") @dynamic_test def test3(self): self.x += 1 - return CheckResult(self.x == 7, 'test3') + return CheckResult(self.x == 7, "test3") def generate(self) -> List[TestCase]: return [ @@ -43,12 +43,12 @@ def generate(self) -> List[TestCase]: def check(self, reply: str, attach: Any) -> CheckResult: self.x += 1 - return CheckResult(self.x == 1, 'test4') + return CheckResult(self.x == 1, "test4") def test5(self, reply: str, attach: Any) -> CheckResult: self.x += 1 - return CheckResult(self.x == 2, 'test4') + return CheckResult(self.x == 2, "test4") def test6(self): self.x += 1 - return CheckResult(self.x == 3, 'test5') + return CheckResult(self.x == 3, "test5") diff --git a/tests/outcomes/lib/success/test.py b/tests/outcomes/lib/success/test.py index f3649263..ea0931cb 100644 --- a/tests/outcomes/lib/success/test.py +++ b/tests/outcomes/lib/success/test.py @@ -9,9 +9,9 @@ class SuccessTest(StageTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin='2\n4', attach='6\n'), - TestCase(stdin='1\n3', attach='4\n'), + TestCase(stdin="2\n4", attach="6\n"), + TestCase(stdin="1\n3", attach="4\n"), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/success2/test.py b/tests/outcomes/lib/success2/test.py index 8b3ed115..0a42f004 100644 --- a/tests/outcomes/lib/success2/test.py +++ b/tests/outcomes/lib/success2/test.py @@ -6,13 +6,13 @@ class SuccessTest(StageTest): - source = 'folder.main' + source = "folder.main" def generate(self) -> List[TestCase]: return [ - TestCase(stdin='2\n4', attach='6\n'), - TestCase(stdin='1\n3', attach='4\n'), + TestCase(stdin="2\n4", attach="6\n"), + TestCase(stdin="1\n3", attach="4\n"), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/test_case_same_objects/main.py b/tests/outcomes/lib/test_case_same_objects/main.py index 988f0aef..2c7e8dd0 100644 --- a/tests/outcomes/lib/test_case_same_objects/main.py +++ b/tests/outcomes/lib/test_case_same_objects/main.py @@ -1,4 +1,4 @@ -print('Hello') +print("Hello") print(input()) print(input()) print(input()) diff --git a/tests/outcomes/lib/test_case_same_objects/test.py b/tests/outcomes/lib/test_case_same_objects/test.py index 90dbe57b..842cc7c5 100644 --- a/tests/outcomes/lib/test_case_same_objects/test.py +++ b/tests/outcomes/lib/test_case_same_objects/test.py @@ -12,4 +12,4 @@ def generate(self) -> List[TestCase]: return [test] * 5 def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/test_copy_to_attach/main.py b/tests/outcomes/lib/test_copy_to_attach/main.py index 083f7da6..93aef0fc 100644 --- a/tests/outcomes/lib/test_copy_to_attach/main.py +++ b/tests/outcomes/lib/test_copy_to_attach/main.py @@ -1 +1 @@ -print(input(), end='') +print(input(), end="") diff --git a/tests/outcomes/lib/test_copy_to_attach/test.py b/tests/outcomes/lib/test_copy_to_attach/test.py index afe5a1d0..ed13bd02 100644 --- a/tests/outcomes/lib/test_copy_to_attach/test.py +++ b/tests/outcomes/lib/test_copy_to_attach/test.py @@ -9,10 +9,10 @@ class TestCopyToAttach(StageTest): def generate(self) -> List[TestCase]: tests = [ - TestCase(stdin='1234', copy_to_attach=True), - TestCase(stdin='4321', copy_to_attach=True) + TestCase(stdin="1234", copy_to_attach=True), + TestCase(stdin="4321", copy_to_attach=True), ] return tests def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/test_curr_test_case/test.py b/tests/outcomes/lib/test_curr_test_case/test.py index 841e21b4..51e8e795 100644 --- a/tests/outcomes/lib/test_curr_test_case/test.py +++ b/tests/outcomes/lib/test_curr_test_case/test.py @@ -10,13 +10,19 @@ class TestCurrTestCase(StageTest): tc_2 = None def generate(self) -> List[TestCase]: - self.tc_1 = TestCase(stdin='1', attach=1) - self.tc_2 = TestCase(stdin='2', attach=2) + self.tc_1 = TestCase(stdin="1", attach=1) + self.tc_2 = TestCase(stdin="2", attach=2) return [self.tc_1, self.tc_2] def check(self, reply: str, attach: Any) -> CheckResult: tc = StageTest.curr_test_run.test_case - if (tc.input == '1' and tc.attach == 1 and tc is self.tc_1 or - tc.input == '2' and tc.attach == 2 and tc is self.tc_2): + if ( + tc.input == "1" + and tc.attach == 1 + and tc is self.tc_1 + or tc.input == "2" + and tc.attach == 2 + and tc is self.tc_2 + ): return CheckResult.correct() - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/lib/test_curr_test_num/test.py b/tests/outcomes/lib/test_curr_test_num/test.py index e4dde863..b954a47d 100644 --- a/tests/outcomes/lib/test_curr_test_num/test.py +++ b/tests/outcomes/lib/test_curr_test_num/test.py @@ -10,12 +10,12 @@ class TestCurrTestNum(StageTest): tc_2 = None def generate(self) -> List[TestCase]: - self.tc_1 = TestCase(stdin='1', attach=1) - self.tc_2 = TestCase(stdin='2', attach=2) + self.tc_1 = TestCase(stdin="1", attach=1) + self.tc_2 = TestCase(stdin="2", attach=2) return [self.tc_1, self.tc_2] def check(self, reply: str, attach: Any) -> CheckResult: tn = StageTest.curr_test_run.test_num - if reply == '1\n' and tn == 1 or reply == '2\n' and tn == 2: + if reply == "1\n" and tn == 1 or reply == "2\n" and tn == 2: return CheckResult.correct() - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/lib/test_custom_checker/main.py b/tests/outcomes/lib/test_custom_checker/main.py index fbe0c3e7..e2138ddc 100644 --- a/tests/outcomes/lib/test_custom_checker/main.py +++ b/tests/outcomes/lib/test_custom_checker/main.py @@ -1,4 +1,4 @@ import sys print(len(sys.argv[1:])) -print(*sys.argv[1:], sep='\n') +print(*sys.argv[1:], sep="\n") diff --git a/tests/outcomes/lib/test_custom_checker/test.py b/tests/outcomes/lib/test_custom_checker/test.py index d38423be..021ef688 100644 --- a/tests/outcomes/lib/test_custom_checker/test.py +++ b/tests/outcomes/lib/test_custom_checker/test.py @@ -9,11 +9,11 @@ class TestCustomChecker(StageTest): def generate(self) -> List[TestCase]: return [ TestCase( - attach='4\n-in\n123\nout\n234\n', - args=['-in', '123', 'out', '234'], - check_function=self.custom_check + attach="4\n-in\n123\nout\n234\n", + args=["-in", "123", "out", "234"], + check_function=self.custom_check, ), ] def custom_check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/test_custom_checker_fail/main.py b/tests/outcomes/lib/test_custom_checker_fail/main.py index fbe0c3e7..e2138ddc 100644 --- a/tests/outcomes/lib/test_custom_checker_fail/main.py +++ b/tests/outcomes/lib/test_custom_checker_fail/main.py @@ -1,4 +1,4 @@ import sys print(len(sys.argv[1:])) -print(*sys.argv[1:], sep='\n') +print(*sys.argv[1:], sep="\n") diff --git a/tests/outcomes/lib/test_custom_checker_fail/test.py b/tests/outcomes/lib/test_custom_checker_fail/test.py index 98de3085..cb55f2eb 100644 --- a/tests/outcomes/lib/test_custom_checker_fail/test.py +++ b/tests/outcomes/lib/test_custom_checker_fail/test.py @@ -7,24 +7,23 @@ class TestCustomChecker(UnexpectedErrorTest): contain = [ - 'Unexpected error in test #2', - 'UnexpectedError: Can\'t ', - 'check result: override "check" method' + "Unexpected error in test #2", + "UnexpectedError: Can't ", + 'check result: override "check" method', ] def generate(self) -> List[TestCase]: return [ TestCase( - attach='4\n-in\n123\nout\n234\n', - args=['-in', '123', 'out', '234'], - check_function=self.custom_check + attach="4\n-in\n123\nout\n234\n", + args=["-in", "123", "out", "234"], + check_function=self.custom_check, ), TestCase( - attach='5\n-in\n435\nout\n567\n789\n', - args=['-in', '435', 'out', '567', '789'] + attach="5\n-in\n435\nout\n567\n789\n", + args=["-in", "435", "out", "567", "789"], ), - ] def custom_check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/lib/test_nbsp_in_output/main.py b/tests/outcomes/lib/test_nbsp_in_output/main.py index d11a0a7e..e5b1be6d 100644 --- a/tests/outcomes/lib/test_nbsp_in_output/main.py +++ b/tests/outcomes/lib/test_nbsp_in_output/main.py @@ -1 +1 @@ -print("1\u00a02 3", end='') +print("1\u00a02 3", end="") diff --git a/tests/outcomes/lib/test_nbsp_in_output/test.py b/tests/outcomes/lib/test_nbsp_in_output/test.py index 931c2038..a17d18e5 100644 --- a/tests/outcomes/lib/test_nbsp_in_output/test.py +++ b/tests/outcomes/lib/test_nbsp_in_output/test.py @@ -8,9 +8,7 @@ class TestNbspInOutput(StageTest): def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == "1\u00202\u00203", '') + return CheckResult(reply == "1\u00202\u00203", "") diff --git a/tests/outcomes/lib/test_run_test_inside_test/test.py b/tests/outcomes/lib/test_run_test_inside_test/test.py index 05574c36..6dd28ea7 100644 --- a/tests/outcomes/lib/test_run_test_inside_test/test.py +++ b/tests/outcomes/lib/test_run_test_inside_test/test.py @@ -15,7 +15,7 @@ class TestRunTestInsideTest(UserErrorTest): @dynamic_test def test(self): - status, feedback = TestRunTestInsideTest('').run_tests() + status, feedback = TestRunTestInsideTest("").run_tests() if status != 0: raise ErrorWithFeedback(feedback) return CheckResult.correct() diff --git a/tests/outcomes/long_output/long_output_on_raise_wrong_answer/test.py b/tests/outcomes/long_output/long_output_on_raise_wrong_answer/test.py index 96202b45..fdb5c77e 100644 --- a/tests/outcomes/long_output/long_output_on_raise_wrong_answer/test.py +++ b/tests/outcomes/long_output/long_output_on_raise_wrong_answer/test.py @@ -1,13 +1,13 @@ -from hstest import dynamic_test, TestedProgram, WrongAnswer +from hstest import TestedProgram, WrongAnswer, dynamic_test from hstest.testing.unittest.user_error_test import UserErrorTest class TestWrongOutputWithTooLongOutput(UserErrorTest): - contain = [f'A {i} line' for i in range(350, 600)] - not_contain = [f'A {i} line' for i in range(0, 350)] + contain = [f"A {i} line" for i in range(350, 600)] + not_contain = [f"A {i} line" for i in range(0, 350)] @dynamic_test def test(self): program = TestedProgram() program.start() - raise WrongAnswer('') + raise WrongAnswer("") diff --git a/tests/outcomes/long_output/long_output_on_unexpected_error/test.py b/tests/outcomes/long_output/long_output_on_unexpected_error/test.py index 05814db2..4a3e5f4b 100644 --- a/tests/outcomes/long_output/long_output_on_unexpected_error/test.py +++ b/tests/outcomes/long_output/long_output_on_unexpected_error/test.py @@ -1,14 +1,14 @@ -from hstest import dynamic_test, TestedProgram, wrong +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.unittest.unexepected_error_test import UnexpectedErrorTest class TestWrongOutputWithTooLongOutput(UnexpectedErrorTest): - contain = [f'A {i} line' for i in range(350, 600)] - not_contain = [f'A {i} line' for i in range(0, 350)] + contain = [f"A {i} line" for i in range(350, 600)] + not_contain = [f"A {i} line" for i in range(0, 350)] @dynamic_test def test(self): program = TestedProgram() program.start() a = 2 / 0 # noqa: F841 - return wrong('') + return wrong("") diff --git a/tests/outcomes/long_output/long_output_with_arguments/test.py b/tests/outcomes/long_output/long_output_with_arguments/test.py index 1fbcce5e..e323f8f9 100644 --- a/tests/outcomes/long_output/long_output_with_arguments/test.py +++ b/tests/outcomes/long_output/long_output_with_arguments/test.py @@ -1,4 +1,4 @@ -from hstest import dynamic_test, TestedProgram, wrong +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.unittest.user_error_test import UserErrorTest @@ -9,4 +9,4 @@ class TestWrongOutputWithTooLongOutput(UserErrorTest): def test(self): program = TestedProgram() program.start("-arg", "test") - return wrong('') + return wrong("") diff --git a/tests/outcomes/long_output/test_label_on_long_output/test.py b/tests/outcomes/long_output/test_label_on_long_output/test.py index 7d2075db..03eb26f7 100644 --- a/tests/outcomes/long_output/test_label_on_long_output/test.py +++ b/tests/outcomes/long_output/test_label_on_long_output/test.py @@ -1,15 +1,15 @@ -from hstest import dynamic_test, TestedProgram, wrong +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.unittest.user_error_test import UserErrorTest class TestWrongOutputWithTooLongOutput(UserErrorTest): - contain = [f'A {i} line' for i in range(1, 250)] + [ - '[last 250 lines of output are shown, 1 skipped]' + contain = [f"A {i} line" for i in range(1, 250)] + [ + "[last 250 lines of output are shown, 1 skipped]" ] - not_contain = [f'A {i} line' for i in range(0, 1)] + not_contain = [f"A {i} line" for i in range(0, 1)] @dynamic_test def test(self): program = TestedProgram() program.start() - return wrong('') + return wrong("") diff --git a/tests/outcomes/long_output/test_label_on_not_enough_long_output/test.py b/tests/outcomes/long_output/test_label_on_not_enough_long_output/test.py index 8bc0145f..a05b9599 100644 --- a/tests/outcomes/long_output/test_label_on_not_enough_long_output/test.py +++ b/tests/outcomes/long_output/test_label_on_not_enough_long_output/test.py @@ -1,13 +1,13 @@ -from hstest import dynamic_test, TestedProgram, wrong +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.unittest.user_error_test import UserErrorTest class TestWrongOutputWithTooLongOutput(UserErrorTest): - contain = [f'A {i} line' for i in range(1, 250)] - not_contain = '[last 250 lines of output are shown, 1 skipped]' + contain = [f"A {i} line" for i in range(1, 250)] + not_contain = "[last 250 lines of output are shown, 1 skipped]" @dynamic_test def test(self): program = TestedProgram() program.start() - return wrong('') + return wrong("") diff --git a/tests/outcomes/long_output/wrong_output_with_too_long_output/test.py b/tests/outcomes/long_output/wrong_output_with_too_long_output/test.py index 9f00a676..efc4e4b3 100644 --- a/tests/outcomes/long_output/wrong_output_with_too_long_output/test.py +++ b/tests/outcomes/long_output/wrong_output_with_too_long_output/test.py @@ -1,13 +1,13 @@ -from hstest import dynamic_test, TestedProgram, wrong +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.unittest.user_error_test import UserErrorTest class TestWrongOutputWithTooLongOutput(UserErrorTest): - contain = [f'A {i} line' for i in range(350, 600)] - not_contain = [f'A {i} line' for i in range(0, 350)] + contain = [f"A {i} line" for i in range(350, 600)] + not_contain = [f"A {i} line" for i in range(0, 350)] @dynamic_test def test(self): program = TestedProgram() program.start() - return wrong('') + return wrong("") diff --git a/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/main.py b/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/main.py index c43b0bb0..0b8b2caf 100644 --- a/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/main.py +++ b/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/main.py @@ -2,8 +2,8 @@ while True: inp = input() - if inp == '': - print('empty') + if inp == "": + print("empty") else: print(inp) i += 1 diff --git a/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/test.py b/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/test.py index a76dd96f..5f77286b 100644 --- a/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/test.py +++ b/tests/outcomes/multiple_empty_line_in_input/test_input_method_with_multiple_empty_line_input/test.py @@ -1,4 +1,4 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class UnexpectedErrorAddInput1(StageTest): @@ -8,28 +8,28 @@ def test(self): program = TestedProgram() program.start() - output = program.execute('test') - if output != 'test\n': - return CheckResult.wrong('') + output = program.execute("test") + if output != "test\n": + return CheckResult.wrong("") - output = program.execute('test\n') - if output != 'test\n': - return CheckResult.wrong('') + output = program.execute("test\n") + if output != "test\n": + return CheckResult.wrong("") - output = program.execute('test\n\n') - if output != 'test\nempty\n': - return CheckResult.wrong('') + output = program.execute("test\n\n") + if output != "test\nempty\n": + return CheckResult.wrong("") - output = program.execute('test\n\n\n') - if output != 'test\nempty\nempty\n': - return CheckResult.wrong('') + output = program.execute("test\n\n\n") + if output != "test\nempty\nempty\n": + return CheckResult.wrong("") - output = program.execute('\ntest\n\n\n') - if output != 'empty\ntest\nempty\nempty\n': - return CheckResult.wrong('') + output = program.execute("\ntest\n\n\n") + if output != "empty\ntest\nempty\nempty\n": + return CheckResult.wrong("") - output = program.execute('test\n\ntest\n\ntest\n\n\n') - if output != 'test\nempty\ntest\nempty\ntest\nempty\nempty\n': - return CheckResult.wrong('') + output = program.execute("test\n\ntest\n\ntest\n\n\n") + if output != "test\nempty\ntest\nempty\ntest\nempty\nempty\n": + return CheckResult.wrong("") return CheckResult.correct() diff --git a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/main.py b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/main.py index 0d33bbd3..47733d25 100644 --- a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/main.py +++ b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/main.py @@ -2,8 +2,8 @@ while True: inp = input() - if inp == '': - print('Empty line') + if inp == "": + print("Empty line") else: print(inp) print(f"Input line number {i}") diff --git a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/test.py b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/test.py index c3a8c4ba..7aa1cad7 100644 --- a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/test.py +++ b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_and_in_the_middle_of_input/test.py @@ -1,4 +1,4 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class UnexpectedErrorAddInput1(StageTest): @@ -6,7 +6,7 @@ class UnexpectedErrorAddInput1(StageTest): ("\ntest", 2), ("\n\ntest\n", 3), ("test\ntest\n\n\ntest\n\n\n", 7), - ("\n\ntest\ntest\ntest\n\n", 6) + ("\n\ntest\ntest\ntest\n\n", 6), ] @dynamic_test(data=data) @@ -15,8 +15,10 @@ def test(self, inp, correct_lines_number): program.start() output = program.execute(inp) - if (f"Input line number {correct_lines_number}" not in output or - f"Input line number {correct_lines_number + 1}" in output): - return CheckResult.wrong('') + if ( + f"Input line number {correct_lines_number}" not in output + or f"Input line number {correct_lines_number + 1}" in output + ): + return CheckResult.wrong("") return CheckResult.correct() diff --git a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/main.py b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/main.py index 0d33bbd3..47733d25 100644 --- a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/main.py +++ b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/main.py @@ -2,8 +2,8 @@ while True: inp = input() - if inp == '': - print('Empty line') + if inp == "": + print("Empty line") else: print(inp) print(f"Input line number {i}") diff --git a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/test.py b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/test.py index 7627baeb..4997e403 100644 --- a/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/test.py +++ b/tests/outcomes/multiple_empty_line_in_input/test_multiple_line_at_the_end_of_input/test.py @@ -1,4 +1,4 @@ -from hstest import CheckResult, dynamic_test, StageTest, TestedProgram +from hstest import CheckResult, StageTest, TestedProgram, dynamic_test class UnexpectedErrorAddInput1(StageTest): @@ -7,7 +7,7 @@ class UnexpectedErrorAddInput1(StageTest): ("test\n", 1), ("test\n\n", 2), ("test\n\n\n", 3), - ("test\n\n\n\n", 4) + ("test\n\n\n\n", 4), ] @dynamic_test(data=data) @@ -16,8 +16,10 @@ def test(self, inp, correct_lines_number): program.start() output = program.execute(inp) - if (f"Input line number {correct_lines_number}" not in output or - f"Input line number {correct_lines_number + 1}" in output): - return CheckResult.wrong('') + if ( + f"Input line number {correct_lines_number}" not in output + or f"Input line number {correct_lines_number + 1}" in output + ): + return CheckResult.wrong("") return CheckResult.correct() diff --git a/tests/outcomes/parametrized_tests/correct/test_parametrized_data/test.py b/tests/outcomes/parametrized_tests/correct/test_parametrized_data/test.py index 04f1474d..0f26f3fd 100644 --- a/tests/outcomes/parametrized_tests/correct/test_parametrized_data/test.py +++ b/tests/outcomes/parametrized_tests/correct/test_parametrized_data/test.py @@ -4,13 +4,7 @@ class TestParametrizedData(StageTest): - test_data = [ - [1, 2], - [2, 3], - [3, 4], - [4, 5], - [5, 6] - ] + test_data = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]] counter = 0 @@ -18,4 +12,4 @@ class TestParametrizedData(StageTest): def test(self, a, b): self.counter += 1 print(a, b) - return CheckResult(self.counter == a and self.counter + 1 == b, '') + return CheckResult(self.counter == a and self.counter + 1 == b, "") diff --git a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_2/test.py b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_2/test.py index 72227d62..ca2c06bd 100644 --- a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_2/test.py +++ b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_2/test.py @@ -12,4 +12,4 @@ class TestParametrizedData2(StageTest): def test(self, a): self.counter += 1 print(a) - return CheckResult(self.counter == a, '') + return CheckResult(self.counter == a, "") diff --git a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_3/test.py b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_3/test.py index 2f34b1b1..4078cbcb 100644 --- a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_3/test.py +++ b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_3/test.py @@ -4,9 +4,7 @@ class TestParametrizedData3(StageTest): - test_data = [ - [1], [2], [3], [4], [5] - ] + test_data = [[1], [2], [3], [4], [5]] counter = 0 @@ -14,4 +12,4 @@ class TestParametrizedData3(StageTest): def test(self, a): self.counter += 1 print(a) - return CheckResult(self.counter == a, '') + return CheckResult(self.counter == a, "") diff --git a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_4/test.py b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_4/test.py index ad909dd5..a4591130 100644 --- a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_4/test.py +++ b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_4/test.py @@ -4,13 +4,7 @@ class TestParametrizedData4(StageTest): - test_data = [ - [1], - [2, 3], - [3, 4, 5], - [4, 5, 6, 7], - [5, 6, 7, 8, 9] - ] + test_data = [[1], [2, 3], [3, 4, 5], [4, 5, 6, 7], [5, 6, 7, 8, 9]] counter = 0 @@ -18,4 +12,4 @@ class TestParametrizedData4(StageTest): def test(self, *a): self.counter += 1 print(a) - return CheckResult(self.counter == len(a), '') + return CheckResult(self.counter == len(a), "") diff --git a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_5/test.py b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_5/test.py index 66b61a46..ac6c9aeb 100644 --- a/tests/outcomes/parametrized_tests/correct/test_parametrized_data_5/test.py +++ b/tests/outcomes/parametrized_tests/correct/test_parametrized_data_5/test.py @@ -4,13 +4,7 @@ class TestParametrizedData5(StageTest): - test_data = [ - [[1]], - [[2, 3]], - [[3, 4, 5]], - [[4, 5, 6, 7]], - [[5, 6, 7, 8, 9]] - ] + test_data = [[[1]], [[2, 3]], [[3, 4, 5]], [[4, 5, 6, 7]], [[5, 6, 7, 8, 9]]] counter = 0 @@ -18,4 +12,4 @@ class TestParametrizedData5(StageTest): def test(self, a): self.counter += 1 print(a) - return CheckResult(self.counter == len(a), '') + return CheckResult(self.counter == len(a), "") diff --git a/tests/outcomes/parametrized_tests/wrong/test_wrong_data/test.py b/tests/outcomes/parametrized_tests/wrong/test_wrong_data/test.py index 8cb582c2..9eb445ce 100644 --- a/tests/outcomes/parametrized_tests/wrong/test_wrong_data/test.py +++ b/tests/outcomes/parametrized_tests/wrong/test_wrong_data/test.py @@ -4,9 +4,11 @@ class TestWrongData(UnexpectedErrorTest): - contain = 'UnexpectedError: Data passed to dynamic method "test" ' \ - 'should be of type "list" or "tuple",' \ - ' found .' + contain = ( + 'UnexpectedError: Data passed to dynamic method "test" ' + 'should be of type "list" or "tuple",' + " found ." + ) test_data = 123 @@ -16,4 +18,4 @@ class TestWrongData(UnexpectedErrorTest): def test(self, a): self.counter += 1 print(a) - return CheckResult(self.counter == len(a), '') + return CheckResult(self.counter == len(a), "") diff --git a/tests/outcomes/parametrized_tests/wrong/test_wrong_data_2/test.py b/tests/outcomes/parametrized_tests/wrong/test_wrong_data_2/test.py index 325f82ec..9342760a 100644 --- a/tests/outcomes/parametrized_tests/wrong/test_wrong_data_2/test.py +++ b/tests/outcomes/parametrized_tests/wrong/test_wrong_data_2/test.py @@ -4,7 +4,9 @@ class TestWrongData2(UnexpectedErrorTest): - contain = 'UnexpectedError: Data passed to dynamic method "test" should not be empty.' + contain = ( + 'UnexpectedError: Data passed to dynamic method "test" should not be empty.' + ) test_data = [] @@ -14,4 +16,4 @@ class TestWrongData2(UnexpectedErrorTest): def test(self, a): self.counter += 1 print(a) - return CheckResult(self.counter == len(a), '') + return CheckResult(self.counter == len(a), "") diff --git a/tests/outcomes/plot/area/pandas/main.py b/tests/outcomes/plot/area/pandas/main.py index cdb7e915..8598c9d1 100644 --- a/tests/outcomes/plot/area/pandas/main.py +++ b/tests/outcomes/plot/area/pandas/main.py @@ -1,19 +1,19 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns import pandas as pd - import numpy as np except ModuleNotFoundError: return - df = pd.DataFrame({ - 'sales': [3, 2, 3, 9, 10, 6], - 'signups': [5, 5, 6, 12, 14, 13], - 'visits': [20, 42, 28, 62, 81, 50], - }, index=pd.date_range(start='2018/01/01', end='2018/07/01', - freq='M')) - ax = df.plot.area() + df = pd.DataFrame( + { + "sales": [3, 2, 3, 9, 10, 6], + "signups": [5, 5, 6, 12, 14, 13], + "visits": [20, 42, 28, 62, 81, 50], + }, + index=pd.date_range(start="2018/01/01", end="2018/07/01", freq="M"), + ) + df.plot.area() plt.show() diff --git a/tests/outcomes/plot/area/test_area_drawing.py b/tests/outcomes/plot/area/test_area_drawing.py index d325421b..4182728d 100644 --- a/tests/outcomes/plot/area/test_area_drawing.py +++ b/tests/outcomes/plot/area/test_area_drawing.py @@ -4,16 +4,18 @@ def test_area_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, area in enumerate(figures): - if area.type != 'area': - return wrong(f'Wrong drawing type {area.type}. Expected area') + if area.type != "area": + return wrong(f"Wrong drawing type {area.type}. Expected area") if area.library != library_type: - return wrong(f'{area.library} is wrong library type. Expected {library_type}') + return wrong( + f"{area.library} is wrong library type. Expected {library_type}" + ) if area.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/bar/matplotlib/main.py b/tests/outcomes/plot/bar/matplotlib/main.py index 483bd2ed..d80d7c8f 100644 --- a/tests/outcomes/plot/bar/matplotlib/main.py +++ b/tests/outcomes/plot/bar/matplotlib/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/matplotlib/test.py b/tests/outcomes/plot/bar/matplotlib/test.py index 4264779f..36bb19c1 100644 --- a/tests/outcomes/plot/bar/matplotlib/test.py +++ b/tests/outcomes/plot/bar/matplotlib/test.py @@ -18,4 +18,6 @@ def test(self): [[1, 8], [2, 8], [4, 8], [6, 8]], ] - return test_bar_drawing(self.all_figures(), correct_data, DrawingLibrary.matplotlib) + return test_bar_drawing( + self.all_figures(), correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/bar/pandas/test_example/cleaning.py b/tests/outcomes/plot/bar/pandas/test_example/cleaning.py index f65f04ac..b085c869 100644 --- a/tests/outcomes/plot/bar/pandas/test_example/cleaning.py +++ b/tests/outcomes/plot/bar/pandas/test_example/cleaning.py @@ -2,12 +2,22 @@ import pandas as pd # Upload data -df_ab = pd.read_csv('ab_test.csv') +df_ab = pd.read_csv("ab_test.csv") # Plot dates -df_ab['date'] = df_ab['date'].astype('datetime64') -control = df_ab[df_ab['group'] == 'Control'].groupby(df_ab['date'].dt.day).size().rename('Control') -experiment = df_ab[df_ab['group'] == 'Experimental'].groupby(df_ab['date'].dt.day).size().rename('Experimental') +df_ab["date"] = df_ab["date"].astype("datetime64") +control = ( + df_ab[df_ab["group"] == "Control"] + .groupby(df_ab["date"].dt.day) + .size() + .rename("Control") +) +experiment = ( + df_ab[df_ab["group"] == "Experimental"] + .groupby(df_ab["date"].dt.day) + .size() + .rename("Experimental") +) control.plot(kind="bar") plt.xlabel("Day") diff --git a/tests/outcomes/plot/bar/pandas/test_example/test.py b/tests/outcomes/plot/bar/pandas/test_example/test.py index 51c7d7f2..41a780c7 100644 --- a/tests/outcomes/plot/bar/pandas/test_example/test.py +++ b/tests/outcomes/plot/bar/pandas/test_example/test.py @@ -1,4 +1,4 @@ -from hstest import dynamic_test, PlottingTest +from hstest import PlottingTest, dynamic_test from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary from hstest.testing.tested_program import TestedProgram from tests.outcomes.plot.bar.test_bar_drawing import test_bar_drawing diff --git a/tests/outcomes/plot/bar/pandas/test_no_args/pandas_dataframe_plot_no_x_no_y.py b/tests/outcomes/plot/bar/pandas/test_no_args/pandas_dataframe_plot_no_x_no_y.py index d8ef1203..c01c113c 100644 --- a/tests/outcomes/plot/bar/pandas/test_no_args/pandas_dataframe_plot_no_x_no_y.py +++ b/tests/outcomes/plot/bar/pandas/test_no_args/pandas_dataframe_plot_no_x_no_y.py @@ -1,13 +1,11 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns import pandas as pd - import numpy as np except ModuleNotFoundError: return - df = pd.DataFrame({'lab': [2, 3, 4, 5, 6], 'val': [3, 4, 5, 6, 7]}) + df = pd.DataFrame({"lab": [2, 3, 4, 5, 6], "val": [3, 4, 5, 6, 7]}) df.plot.bar() diff --git a/tests/outcomes/plot/bar/seaborn/main.py b/tests/outcomes/plot/bar/seaborn/main.py index 04d726b3..f928ddf8 100644 --- a/tests/outcomes/plot/bar/seaborn/main.py +++ b/tests/outcomes/plot/bar/seaborn/main.py @@ -1,21 +1,22 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns import pandas as pd - import numpy as np + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame({'lab': ['A', 'B', 'C'], 'val': [10, 30, 20], 'val1': [5, 10, 15]}) + df = pd.DataFrame( + {"lab": ["A", "B", "C"], "val": [10, 30, 20], "val1": [5, 10, 15]} + ) - sns.barplot(x='lab', y='val', data=df) + sns.barplot(x="lab", y="val", data=df) plt.show() - sns.barplot(y='val', data=df) + sns.barplot(y="val", data=df) plt.show() - sns.barplot(x='val', data=df) + sns.barplot(x="val", data=df) plt.show() diff --git a/tests/outcomes/plot/bar/seaborn/test.py b/tests/outcomes/plot/bar/seaborn/test.py index 2a45afbd..7e82d12d 100644 --- a/tests/outcomes/plot/bar/seaborn/test.py +++ b/tests/outcomes/plot/bar/seaborn/test.py @@ -13,10 +13,15 @@ def test(self): program = TestedProgram() program.start() - correct_data = np.array([ - [['A', 10], ['B', 30], ['C', 20]], - [['', 10], ['', 30], ['', 20]], - [[10, ''], [30, ''], [20, '']], - ], dtype=object) + correct_data = np.array( + [ + [["A", 10], ["B", 30], ["C", 20]], + [["", 10], ["", 30], ["", 20]], + [[10, ""], [30, ""], [20, ""]], + ], + dtype=object, + ) - return test_bar_drawing(self.all_figures(), correct_data, DrawingLibrary.seaborn) + return test_bar_drawing( + self.all_figures(), correct_data, DrawingLibrary.seaborn + ) diff --git a/tests/outcomes/plot/bar/test_bar_drawing.py b/tests/outcomes/plot/bar/test_bar_drawing.py index 390ddbcc..186aada6 100644 --- a/tests/outcomes/plot/bar/test_bar_drawing.py +++ b/tests/outcomes/plot/bar/test_bar_drawing.py @@ -9,16 +9,18 @@ def test_bar_drawing(figures, correct_data, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, bar in enumerate(figures): - if bar.type != 'bar': - return wrong(f'Wrong drawing type {bar.type}. Expected bar') + if bar.type != "bar": + return wrong(f"Wrong drawing type {bar.type}. Expected bar") if bar.library != library_type: - return wrong(f'{bar.library} is wrong library type. Expected {library_type}') + return wrong( + f"{bar.library} is wrong library type. Expected {library_type}" + ) if not isinstance(bar.data, DrawingData): return wrong("The data value should be a ndarray") @@ -26,9 +28,9 @@ def test_bar_drawing(figures, correct_data, library_type): current_correct = np.array(correct_data[i], dtype=object) if not np.array_equal(current_correct[:, 0], bar.data.x): - return wrong('Wrong x data of the bar graph') + return wrong("Wrong x data of the bar graph") if not np.array_equal(current_correct[:, 1], bar.data.y): - return wrong('Wrong y data of the bar graph') + return wrong("Wrong y data of the bar graph") return correct() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot.py index fbf2f323..7c914a97 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) df.one.plot.bar() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot_kind.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot_kind.py index cfdd7755..515f9723 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot_kind.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_plot_kind.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.one.plot(kind='bar') + df.one.plot(kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot.py index fa34a0e4..4d26aca9 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df['one'].plot.bar() + df["one"].plot.bar() plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot_kind.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot_kind.py index e871c69f..487de613 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot_kind.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_column_string_plot_kind.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df['one'].plot(kind='bar') + df["one"].plot(kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot.py index b0d5d81d..f6efbbd9 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot.py @@ -1,13 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) df.plot.bar() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind.py index 64723597..b02af950 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind.py @@ -1,15 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) - df.plot(kind='bar') + df.plot(kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind_y.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind_y.py index c8257516..c886a781 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind_y.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_kind_y.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot(y='one', kind='bar') + df.plot(y="one", kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_y.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_y.py index 377ef5b6..73169de0 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_y.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_dataframe_plot_y.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot.bar(y='one') + df.plot.bar(y="one") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot.py index cbab2b8e..2667fe44 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot_kind.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot_kind.py index 3af2f3b7..63c921a8 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot_kind.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/pandas_series_plot_kind.py @@ -1,13 +1,13 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return ser = pd.Series(data=np.array([1, 2, 3, 4, 5])) - ser.plot(kind='bar') + ser.plot(kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_no_x/test.py b/tests/outcomes/plot/bar/universal_tests/data_no_x/test.py index 52b0680b..88f39b46 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_no_x/test.py +++ b/tests/outcomes/plot/bar/universal_tests/data_no_x/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -19,11 +19,7 @@ def test(self): return wrong("hs-test-python didn't run requested file") universal_test( - file, - 'bar', - [[0, 1, 2, 3, 4]], - [[1, 2, 3, 4, 5]], - self.new_figures() + file, "bar", [[0, 1, 2, 3, 4]], [[1, 2, 3, 4, 5]], self.new_figures() ) return correct() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_ax.py index 406f4881..844f038d 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_ax.py @@ -1,17 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - ax.bar(x='one', height='two', data=df) + ax.bar(x="one", height="two", data=df) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_plt.py index daf86ed7..8e59555e 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_data_dataframe_plt.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - plt.bar(x='one', height='two', data=df) + plt.bar(x="one", height="two", data=df) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_ax.py index 1b04b94d..d9f28bce 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_ax.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_plt.py index fa96a23c..8b17192c 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_array_plt.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_ax.py index e554e99c..fdb8572d 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_ax.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) ax.bar(df.one, df.two) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_plt.py index 0c47b83a..f836b826 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_plt.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) plt.bar(df.one, df.two) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_ax.py index 72988855..fe24efd6 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_ax.py @@ -1,17 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - ax.bar(df['one'], df['two']) + ax.bar(df["one"], df["two"]) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_plt.py index c460d965..05ceacaf 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_column_string_plt.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - plt.bar(df['one'], df['two']) + plt.bar(df["one"], df["two"]) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_ax.py index d81819c7..5d478bf5 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_ax.py @@ -1,15 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) ax.bar(df.one, height=np.array([2, 3, 4, 5, 6])) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_plt.py index 624d311e..3d5388b4 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_dataframe_plt.py @@ -1,15 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) - plt.bar(df['one'], height=np.array([2, 3, 4, 5, 6])) + plt.bar(df["one"], height=np.array([2, 3, 4, 5, 6])) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_ax.py index ae1582ee..27e7a765 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_plt.py index 1f603125..766a088c 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_list_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_ax.py index bfbbf236..ed088fdb 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_ax.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_plt.py index a4251746..dba791d9 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_series_plt.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_ax.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_ax.py index 2e327af7..0adea430 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_ax.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_plt.py b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_plt.py index 676a43ec..14e40824 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_plt.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/matplotlib_x_tuple_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py index c6cbabc2..9d72b577 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot(x='one', kind='bar') + df.plot(x="one", kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py index ae2f17a0..8ce2eaf8 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot(x='one', y='two', kind='bar') + df.plot(x="one", y="two", kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_x.py b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_x.py index 7613d3fe..e1985de8 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_x.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_x.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot.bar(x='one') + df.plot.bar(x="one") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_xy.py b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_xy.py index ae2f17a0..8ce2eaf8 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_xy.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_dataframe_plot_xy.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot(x='one', y='two', kind='bar') + df.plot(x="one", y="two", kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_series_plot_kind.py b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_series_plot_kind.py index 8c8aee52..b86ed48f 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_series_plot_kind.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/pandas_series_plot_kind.py @@ -1,13 +1,13 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return ser = pd.Series(data=np.array([1, 2, 3, 4, 5, 6])) - ser[1:].plot(kind='bar') + ser[1:].plot(kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_simple/test.py b/tests/outcomes/plot/bar/universal_tests/data_simple/test.py index 69fa9475..82b2542f 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_simple/test.py +++ b/tests/outcomes/plot/bar/universal_tests/data_simple/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -19,11 +19,7 @@ def test(self): return wrong("hs-test-python didn't run requested file") universal_test( - file, - 'bar', - [[1, 2, 3, 4, 5]], - [[2, 3, 4, 5, 6]], - self.new_figures() + file, "bar", [[1, 2, 3, 4, 5]], [[2, 3, 4, 5, 6]], self.new_figures() ) return correct() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_x.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_x.py index b544378e..10ad4e8b 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_x.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_x.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot(x='one', kind='bar') + df.plot(x="one", kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_xy.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_xy.py index 7af5c8b7..73aad436 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_xy.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_kind_xy.py @@ -1,15 +1,19 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]), - columns=['one', 'two', 'three', 'four']) + df = pd.DataFrame( + np.array( + [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]] + ), + columns=["one", "two", "three", "four"], + ) - df.plot(x='one', y=['two', 'three'], kind='bar') + df.plot(x="one", y=["two", "three"], kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_x.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_x.py index f51e6d4f..95f9786c 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_x.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_x.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot.bar(x='one') + df.plot.bar(x="one") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_xy.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_xy.py index f50e3950..6f49960d 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_xy.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics/pandas_dataframe_plot_xy.py @@ -1,15 +1,19 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]), - columns=['one', 'two', 'three', 'four']) + df = pd.DataFrame( + np.array( + [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]] + ), + columns=["one", "two", "three", "four"], + ) - df.plot.bar(x='one', y=['two', 'three']) + df.plot.bar(x="one", y=["two", "three"]) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics/test.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics/test.py index 8db3b717..dc91ae64 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics/test.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -20,10 +20,10 @@ def test(self): universal_test( file, - 'bar', + "bar", [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]], [[2, 3, 4, 5, 6], [3, 4, 5, 6, 7]], - self.new_figures() + self.new_figures(), ) return correct() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot.py index eb462bba..f93201bc 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) df.plot.bar() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind.py index 3508cbf5..78c97970 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot(kind='bar') + df.plot(kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind_y.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind_y.py index 2a86c220..ccee3c4e 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind_y.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_kind_y.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot(y=['one', 'two'], kind='bar') + df.plot(y=["one", "two"], kind="bar") plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_y.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_y.py index 026a103d..4109e7c2 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_y.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/pandas_dataframe_plot_y.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), - columns=['one', 'two', 'three']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]), + columns=["one", "two", "three"], + ) - df.plot.bar(y=['one', 'two']) + df.plot.bar(y=["one", "two"]) plt.show() diff --git a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/test.py b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/test.py index 2c1f8cb4..dabe013b 100644 --- a/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/test.py +++ b/tests/outcomes/plot/bar/universal_tests/data_two_pics_no_x/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -20,10 +20,10 @@ def test(self): universal_test( file, - 'bar', + "bar", [[0, 1, 2, 3, 4], [0, 1, 2, 3, 4]], [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6]], - self.new_figures() + self.new_figures(), ) return correct() diff --git a/tests/outcomes/plot/box/matplotlib/test_data/main.py b/tests/outcomes/plot/box/matplotlib/test_data/main.py index 67abd625..8d146c11 100644 --- a/tests/outcomes/plot/box/matplotlib/test_data/main.py +++ b/tests/outcomes/plot/box/matplotlib/test_data/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/box/matplotlib/test_data_2/main.py b/tests/outcomes/plot/box/matplotlib/test_data_2/main.py index 922d77df..6e224d56 100644 --- a/tests/outcomes/plot/box/matplotlib/test_data_2/main.py +++ b/tests/outcomes/plot/box/matplotlib/test_data_2/main.py @@ -8,11 +8,41 @@ prenatal.columns = general.columns sports.columns = general.columns df = pd.concat([general, prenatal, sports], ignore_index=True) -df.drop('Unnamed: 0', inplace=True, axis=1) -df.dropna(how='all', inplace=True) -df.gender.replace({'female': 'f', 'woman': 'f', 'man': 'm', 'male': 'm'}, inplace=True) -df.loc[df['hospital' == prenatal].index, 'gender'] = df.loc[df['hospital' == prenatal].index, 'gender'].fillna('f') -df.loc[:, ['bmi', 'diagnosis', 'blood_test', 'ecg', 'ultrasound', 'mri', 'xray', 'children', 'months']] = df.loc[:, ['bmi', 'diagnosis', 'blood_test', 'ecg', 'ultrasound', 'mri', 'xray', 'children', 'months']].fillna(0) +df.drop("Unnamed: 0", inplace=True, axis=1) +df.dropna(how="all", inplace=True) +df.gender.replace({"female": "f", "woman": "f", "man": "m", "male": "m"}, inplace=True) +df.loc[df["hospital" == prenatal].index, "gender"] = df.loc[ + df["hospital" == prenatal].index, "gender" +].fillna("f") +df.loc[ + :, + [ + "bmi", + "diagnosis", + "blood_test", + "ecg", + "ultrasound", + "mri", + "xray", + "children", + "months", + ], +] = df.loc[ + :, + [ + "bmi", + "diagnosis", + "blood_test", + "ecg", + "ultrasound", + "mri", + "xray", + "children", + "months", + ], +].fillna( + 0 +) # this figure tests see as 6 figures # pandas @@ -21,13 +51,13 @@ # pie chart # pandas -df.diagnosis.value_counts().plot(kind='pie') +df.diagnosis.value_counts().plot(kind="pie") plt.show() # seaborn -sns.violinplot(x='height', data=df) +sns.violinplot(x="height", data=df) plt.show() -print('The answer to the 1st question: 15 - 35') -print(f'The answer to the 2nd question: pregnancy') -print('The answer to the 3rd question: something') +print("The answer to the 1st question: 15 - 35") +print(f"The answer to the 2nd question: pregnancy") +print("The answer to the 3rd question: something") diff --git a/tests/outcomes/plot/box/matplotlib/test_data_2/test.py b/tests/outcomes/plot/box/matplotlib/test_data_2/test.py index ef85d340..ee5f086c 100644 --- a/tests/outcomes/plot/box/matplotlib/test_data_2/test.py +++ b/tests/outcomes/plot/box/matplotlib/test_data_2/test.py @@ -3,9 +3,7 @@ class EDATest(PlottingTest): def generate(self): - return [ - TestCase() - ] + return [TestCase()] def check(self, reply, attach): all_figures = self.all_figures() @@ -17,5 +15,5 @@ def check(self, reply, attach): return CheckResult.correct() -if __name__ == '__main__': +if __name__ == "__main__": EDATest().run_tests() diff --git a/tests/outcomes/plot/box/pandas/main.py b/tests/outcomes/plot/box/pandas/main.py index 2b495c73..cf7c02da 100644 --- a/tests/outcomes/plot/box/pandas/main.py +++ b/tests/outcomes/plot/box/pandas/main.py @@ -1,17 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt - import seaborn as sns + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.random.randn(10, 2), - columns=['Col1', 'Col2']) - df['X'] = pd.Series(['A', 'A', 'A', 'A', 'A', - 'B', 'B', 'B', 'B', 'B']) - boxplot = df.boxplot(by='X') + df = pd.DataFrame(np.random.randn(10, 2), columns=["Col1", "Col2"]) + df["X"] = pd.Series(["A", "A", "A", "A", "A", "B", "B", "B", "B", "B"]) + boxplot = df.boxplot(by="X") plt.show() diff --git a/tests/outcomes/plot/box/seaborn/main.py b/tests/outcomes/plot/box/seaborn/main.py index 82c26d01..f0f5845a 100644 --- a/tests/outcomes/plot/box/seaborn/main.py +++ b/tests/outcomes/plot/box/seaborn/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt import seaborn as sns except ModuleNotFoundError: diff --git a/tests/outcomes/plot/box/test_box_drawing.py b/tests/outcomes/plot/box/test_box_drawing.py index 87a9ab8c..02e5d611 100644 --- a/tests/outcomes/plot/box/test_box_drawing.py +++ b/tests/outcomes/plot/box/test_box_drawing.py @@ -4,16 +4,18 @@ def test_box_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, box in enumerate(figures): - if box.type != 'box': - return wrong(f'Wrong drawing type {box.type}. Expected box') + if box.type != "box": + return wrong(f"Wrong drawing type {box.type}. Expected box") if box.library != library_type: - return wrong(f'{box.library} is wrong library type. Expected {library_type}') + return wrong( + f"{box.library} is wrong library type. Expected {library_type}" + ) if box.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/cat/seaborn/main.py b/tests/outcomes/plot/cat/seaborn/main.py index 73807a4c..a9987edf 100644 --- a/tests/outcomes/plot/cat/seaborn/main.py +++ b/tests/outcomes/plot/cat/seaborn/main.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/cat/test_cat_drawing.py b/tests/outcomes/plot/cat/test_cat_drawing.py index ae84d72c..061abb7f 100644 --- a/tests/outcomes/plot/cat/test_cat_drawing.py +++ b/tests/outcomes/plot/cat/test_cat_drawing.py @@ -4,16 +4,18 @@ def test_cat_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, cat in enumerate(figures): - if cat.type != 'cat': - return wrong(f'Wrong drawing type {cat.type}. Expected cat') + if cat.type != "cat": + return wrong(f"Wrong drawing type {cat.type}. Expected cat") if cat.library != library_type: - return wrong(f'{cat.library} is wrong library type. Expected {library_type}') + return wrong( + f"{cat.library} is wrong library type. Expected {library_type}" + ) if cat.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/dis/pandas/main.py b/tests/outcomes/plot/dis/pandas/main.py index 6dbd2925..5744fe2f 100644 --- a/tests/outcomes/plot/dis/pandas/main.py +++ b/tests/outcomes/plot/dis/pandas/main.py @@ -1,14 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt - import seaborn as sns + import pandas as pd except ModuleNotFoundError: return s = pd.Series([1, 2, 2.5, 3, 3.5, 4, 5]) - ax = s.plot.kde() + s.plot.kde() plt.show() diff --git a/tests/outcomes/plot/dis/seaborn/main.py b/tests/outcomes/plot/dis/seaborn/main.py index 2a08068e..52790566 100644 --- a/tests/outcomes/plot/dis/seaborn/main.py +++ b/tests/outcomes/plot/dis/seaborn/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt import seaborn as sns except ModuleNotFoundError: diff --git a/tests/outcomes/plot/dis/test_dis_drawing.py b/tests/outcomes/plot/dis/test_dis_drawing.py index 21ff40aa..898960b0 100644 --- a/tests/outcomes/plot/dis/test_dis_drawing.py +++ b/tests/outcomes/plot/dis/test_dis_drawing.py @@ -4,16 +4,18 @@ def test_dis_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, dis in enumerate(figures): - if dis.type != 'dis': - return wrong(f'Wrong drawing type {dis.type}. Expected dis') + if dis.type != "dis": + return wrong(f"Wrong drawing type {dis.type}. Expected dis") if dis.library != library_type: - return wrong(f'{dis.library} is wrong library type. Expected {library_type}') + return wrong( + f"{dis.library} is wrong library type. Expected {library_type}" + ) if dis.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/heatmap/matplotlib/main.py b/tests/outcomes/plot/heatmap/matplotlib/main.py index 82415df2..2615e044 100644 --- a/tests/outcomes/plot/heatmap/matplotlib/main.py +++ b/tests/outcomes/plot/heatmap/matplotlib/main.py @@ -1,20 +1,23 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return fig, ax = plt.subplots(figsize=(1, 2)) - harvest = np.array([[0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0], - [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0], - [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0], - [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0], - [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0], - [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1], - [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3]]) + harvest = np.array( + [ + [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0], + [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0], + [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0], + [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0], + [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0], + [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1], + [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3], + ] + ) ax.imshow(harvest) diff --git a/tests/outcomes/plot/heatmap/matplotlib/test.py b/tests/outcomes/plot/heatmap/matplotlib/test.py index b443bc9b..6183cd2b 100644 --- a/tests/outcomes/plot/heatmap/matplotlib/test.py +++ b/tests/outcomes/plot/heatmap/matplotlib/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.heatmap.test_heatmap_drawing import test_heatmap_drawing +from tests.outcomes.plot.heatmap.test_heatmap_drawing import \ + test_heatmap_drawing class TestMatplotlibHeatmap(PlottingTest): diff --git a/tests/outcomes/plot/heatmap/seaborn/main.py b/tests/outcomes/plot/heatmap/seaborn/main.py index 53a3f405..885b2865 100644 --- a/tests/outcomes/plot/heatmap/seaborn/main.py +++ b/tests/outcomes/plot/heatmap/seaborn/main.py @@ -1,21 +1,24 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np import seaborn as sns except ModuleNotFoundError: return fig, ax = plt.subplots(figsize=(1, 2)) - harvest = np.array([[0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0], - [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0], - [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0], - [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0], - [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0], - [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1], - [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3]]) + harvest = np.array( + [ + [0.8, 2.4, 2.5, 3.9, 0.0, 4.0, 0.0], + [2.4, 0.0, 4.0, 1.0, 2.7, 0.0, 0.0], + [1.1, 2.4, 0.8, 4.3, 1.9, 4.4, 0.0], + [0.6, 0.0, 0.3, 0.0, 3.1, 0.0, 0.0], + [0.7, 1.7, 0.6, 2.6, 2.2, 6.2, 0.0], + [1.3, 1.2, 0.0, 0.0, 0.0, 3.2, 5.1], + [0.1, 2.0, 0.0, 1.4, 0.0, 1.9, 6.3], + ] + ) ax = sns.heatmap(harvest, center=0) diff --git a/tests/outcomes/plot/heatmap/seaborn/test.py b/tests/outcomes/plot/heatmap/seaborn/test.py index ce5c5048..4752e043 100644 --- a/tests/outcomes/plot/heatmap/seaborn/test.py +++ b/tests/outcomes/plot/heatmap/seaborn/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.heatmap.test_heatmap_drawing import test_heatmap_drawing +from tests.outcomes.plot.heatmap.test_heatmap_drawing import \ + test_heatmap_drawing class TestSeabornHeatmap(PlottingTest): diff --git a/tests/outcomes/plot/heatmap/test_heatmap_drawing.py b/tests/outcomes/plot/heatmap/test_heatmap_drawing.py index eec6732a..75777e6b 100644 --- a/tests/outcomes/plot/heatmap/test_heatmap_drawing.py +++ b/tests/outcomes/plot/heatmap/test_heatmap_drawing.py @@ -4,16 +4,18 @@ def test_heatmap_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, heatmap in enumerate(figures): - if heatmap.type != 'heatmap': - return wrong(f'Wrong drawing type {heatmap.type}. Expected heatmap') + if heatmap.type != "heatmap": + return wrong(f"Wrong drawing type {heatmap.type}. Expected heatmap") if heatmap.library != library_type: - return wrong(f'{heatmap.library} is wrong library type. Expected {library_type}') + return wrong( + f"{heatmap.library} is wrong library type. Expected {library_type}" + ) if heatmap.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/hexbin/pandas/main.py b/tests/outcomes/plot/hexbin/pandas/main.py index a037fa44..5e766d5e 100644 --- a/tests/outcomes/plot/hexbin/pandas/main.py +++ b/tests/outcomes/plot/hexbin/pandas/main.py @@ -1,16 +1,14 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd except ModuleNotFoundError: return n = 10000 - df = pd.DataFrame({'x': np.random.randn(n), - 'y': np.random.randn(n)}) - ax = df.plot.hexbin(x='x', y='y', gridsize=20) + df = pd.DataFrame({"x": np.random.randn(n), "y": np.random.randn(n)}) + ax = df.plot.hexbin(x="x", y="y", gridsize=20) plt.show() diff --git a/tests/outcomes/plot/hexbin/test_hexbin_drawing.py b/tests/outcomes/plot/hexbin/test_hexbin_drawing.py index 458924ac..71fe2491 100644 --- a/tests/outcomes/plot/hexbin/test_hexbin_drawing.py +++ b/tests/outcomes/plot/hexbin/test_hexbin_drawing.py @@ -4,16 +4,18 @@ def test_hexbin_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, hexbin in enumerate(figures): - if hexbin.type != 'hexbin': - return wrong(f'Wrong drawing type {hexbin.type}. Expected hexbin') + if hexbin.type != "hexbin": + return wrong(f"Wrong drawing type {hexbin.type}. Expected hexbin") if hexbin.library != library_type: - return wrong(f'{hexbin.library} is wrong library type. Expected {library_type}') + return wrong( + f"{hexbin.library} is wrong library type. Expected {library_type}" + ) if hexbin.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/hist/matplotlib/test_data/main.py b/tests/outcomes/plot/hist/matplotlib/test_data/main.py index a23dc2bb..ec1f9f40 100644 --- a/tests/outcomes/plot/hist/matplotlib/test_data/main.py +++ b/tests/outcomes/plot/hist/matplotlib/test_data/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return @@ -10,9 +8,9 @@ def plot(): ax.hist([1, 2, 3, 4, 5]) plt.hist([1.4, 5, 1, 2, 6, 5]) - plt.hist([1, 4, 2, '1']) - plt.hist(['1', 'a', '5', '2', 'b', 'bb', 'aa']) - plt.hist([1.1, 5, 2, '1.1', '5']) + plt.hist([1, 4, 2, "1"]) + plt.hist(["1", "a", "5", "2", "b", "bb", "aa"]) + plt.hist([1.1, 5, 2, "1.1", "5"]) plt.hist([1.1, 2.5, 2.1, 1.5, 3.6]) plt.show() diff --git a/tests/outcomes/plot/hist/matplotlib/test_data/test.py b/tests/outcomes/plot/hist/matplotlib/test_data/test.py index 6c3c869a..eb54763a 100644 --- a/tests/outcomes/plot/hist/matplotlib/test_data/test.py +++ b/tests/outcomes/plot/hist/matplotlib/test_data/test.py @@ -14,10 +14,12 @@ def test(self): correct_data = [ [1, 2, 3, 4, 5], [1.4, 5, 1, 2, 6, 5], - [1, 4, 2, '1'], - ['1', 'a', '5', '2', 'b', 'bb', 'aa'], - [1.1, 5, 2, '1.1', '5'], - [1.1, 2.5, 2.1, 1.5, 3.6] + [1, 4, 2, "1"], + ["1", "a", "5", "2", "b", "bb", "aa"], + [1.1, 5, 2, "1.1", "5"], + [1.1, 2.5, 2.1, 1.5, 3.6], ] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.matplotlib) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/hist/matplotlib/test_sorting_data/main.py b/tests/outcomes/plot/hist/matplotlib/test_sorting_data/main.py index 89398f3f..b9c3498d 100644 --- a/tests/outcomes/plot/hist/matplotlib/test_sorting_data/main.py +++ b/tests/outcomes/plot/hist/matplotlib/test_sorting_data/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return @@ -9,11 +7,11 @@ def plot(): fig, ax = plt.subplots(figsize=(1, 2)) plt.hist([3, 2, 1]) - plt.hist([3, 2, '1']) - plt.hist(['3', '2', '1']) + plt.hist([3, 2, "1"]) + plt.hist(["3", "2", "1"]) plt.hist([3.1, 2.1, 1]) - plt.hist(['b', 'a', 'c']) - plt.hist([1, 5, 2, '1']) + plt.hist(["b", "a", "c"]) + plt.hist([1, 5, 2, "1"]) plt.show() diff --git a/tests/outcomes/plot/hist/matplotlib/test_sorting_data/test.py b/tests/outcomes/plot/hist/matplotlib/test_sorting_data/test.py index fc3d4d39..dd6245e9 100644 --- a/tests/outcomes/plot/hist/matplotlib/test_sorting_data/test.py +++ b/tests/outcomes/plot/hist/matplotlib/test_sorting_data/test.py @@ -13,11 +13,13 @@ def test(self): correct_data = [ [3, 2, 1], - [3, 2, '1'], - ['3', '2', '1'], + [3, 2, "1"], + ["3", "2", "1"], [3.1, 2.1, 1], - ['b', 'a', 'c'], - [1, 5, 2, '1'] + ["b", "a", "c"], + [1, 5, 2, "1"], ] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.matplotlib) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/main.py b/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/main.py index 4cfa7640..a0513211 100644 --- a/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/main.py +++ b/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/main.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - plt.hist(x='one', weights='two', data=df) + plt.hist(x="one", weights="two", data=df) plt.show() + plot() diff --git a/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/test.py b/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/test.py index 2656122c..e67259b9 100644 --- a/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/test.py +++ b/tests/outcomes/plot/hist/matplotlib/todo/x_data_with_weights_plt/test.py @@ -12,8 +12,8 @@ def test(self): program.start() # should take into account "weights" column as well, not use weight=1 - correct_data = [ - [1, 2, 3, 4, 5] - ] + correct_data = [[1, 2, 3, 4, 5]] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.matplotlib) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/main.py b/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/main.py index 55de35c1..134199a9 100644 --- a/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/main.py +++ b/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/main.py @@ -1,15 +1,17 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) plt.hist(df) plt.show() + plot() diff --git a/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/test.py b/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/test.py index d594353f..c449eac2 100644 --- a/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/test.py +++ b/tests/outcomes/plot/hist/matplotlib/todo/x_dataframe_plt/test.py @@ -12,9 +12,8 @@ def test(self): program.start() # To be decided what to do with this, for now 2 graphs instead of 1 - correct_data = [ - [1, 2, 3, 4, 5], - [2, 3, 4, 5, 6] - ] + correct_data = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6]] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.matplotlib) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/hist/pandas/test_data/main.py b/tests/outcomes/plot/hist/pandas/test_data/main.py index 31ab6cbf..60f89647 100644 --- a/tests/outcomes/plot/hist/pandas/test_data/main.py +++ b/tests/outcomes/plot/hist/pandas/test_data/main.py @@ -1,22 +1,21 @@ def plot(): try: - import pandas as pd import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=['one']) - df['two'] = df['one'] + np.array([1, 7, 3, 2, 1]) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) + df["two"] = df["one"] + np.array([1, 7, 3, 2, 1]) df.plot.hist(bins=12, alpha=0.5) - df.plot(kind='hist', bins=12, alpha=0.5) - - df.plot(y='one', kind='hist') + df.plot(kind="hist", bins=12, alpha=0.5) - df.plot(x='one', kind='hist') + df.plot(y="one", kind="hist") + df.plot(x="one", kind="hist") - d = {'a': 1, 'b': 2, 'c': 3} + d = {"a": 1, "b": 2, "c": 3} ser = pd.Series(data=np.array([1, 2, 3, 4, 5])) ser.hist() diff --git a/tests/outcomes/plot/hist/pandas/test_data/test.py b/tests/outcomes/plot/hist/pandas/test_data/test.py index 9ab4c043..1462c66e 100644 --- a/tests/outcomes/plot/hist/pandas/test_data/test.py +++ b/tests/outcomes/plot/hist/pandas/test_data/test.py @@ -19,7 +19,9 @@ def test(self): [2, 9, 6, 6, 6], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], - [1, 2, 3, 4, 5] + [1, 2, 3, 4, 5], ] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.pandas) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.pandas + ) diff --git a/tests/outcomes/plot/hist/pandas/test_group_by/main.py b/tests/outcomes/plot/hist/pandas/test_group_by/main.py index c9a16213..211b2e47 100644 --- a/tests/outcomes/plot/hist/pandas/test_group_by/main.py +++ b/tests/outcomes/plot/hist/pandas/test_group_by/main.py @@ -2,17 +2,16 @@ import pandas as pd # Upload data -df_ab = pd.read_csv('ab_test.csv') +df_ab = pd.read_csv("ab_test.csv") # Plot session duration with pandas features -df_ab.hist(column='session_duration', by=df_ab['group'], bins=10) +df_ab.hist(column="session_duration", by=df_ab["group"], bins=10) plt.suptitle("Session duration") plt.show() # Plot session duration with matplotlib subplots fig, (ax1, ax2) = plt.subplots(1, 2) -fig.suptitle('Subplots for session duration') -ax1.hist(df_ab[df_ab['group'] == 'Control']['session_duration']) -ax2.hist(df_ab[df_ab['group'] == 'Experimental']['session_duration']) +fig.suptitle("Subplots for session duration") +ax1.hist(df_ab[df_ab["group"] == "Control"]["session_duration"]) +ax2.hist(df_ab[df_ab["group"] == "Experimental"]["session_duration"]) plt.show() - diff --git a/tests/outcomes/plot/hist/pandas/test_sorting_data/main.py b/tests/outcomes/plot/hist/pandas/test_sorting_data/main.py index 586c1baf..ce6dbbf4 100644 --- a/tests/outcomes/plot/hist/pandas/test_sorting_data/main.py +++ b/tests/outcomes/plot/hist/pandas/test_sorting_data/main.py @@ -1,14 +1,14 @@ def plot(): try: - import pandas as pd import numpy as np + import pandas as pd except ModuleNotFoundError: return ser1 = pd.Series(data=np.array([3, 2, 1])) - ser3 = pd.Series(data=np.array(['3', '2', '1'])) + ser3 = pd.Series(data=np.array(["3", "2", "1"])) ser4 = pd.Series(data=np.array([3.1, 2.1, 1])) - ser5 = pd.Series(data=np.array(['b', 'a', 'c'])) + ser5 = pd.Series(data=np.array(["b", "a", "c"])) ser1.hist() ser3.hist() diff --git a/tests/outcomes/plot/hist/pandas/test_sorting_data/test.py b/tests/outcomes/plot/hist/pandas/test_sorting_data/test.py index 64eab1d1..74ed021b 100644 --- a/tests/outcomes/plot/hist/pandas/test_sorting_data/test.py +++ b/tests/outcomes/plot/hist/pandas/test_sorting_data/test.py @@ -12,11 +12,8 @@ def test(self): program = TestedProgram() program.start() - correct_data = [ - [3, 2, 1], - ['3', '2', '1'], - [3.1, 2.1, 1], - ['b', 'a', 'c'] - ] + correct_data = [[3, 2, 1], ["3", "2", "1"], [3.1, 2.1, 1], ["b", "a", "c"]] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.pandas) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.pandas + ) diff --git a/tests/outcomes/plot/hist/seaborn/test_data/main.py b/tests/outcomes/plot/hist/seaborn/test_data/main.py index e4dfca80..6a13db29 100644 --- a/tests/outcomes/plot/hist/seaborn/test_data/main.py +++ b/tests/outcomes/plot/hist/seaborn/test_data/main.py @@ -1,23 +1,19 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([5, 2, 1, 4, 5, 3]), columns=['one']) + df = pd.DataFrame(np.array([5, 2, 1, 4, 5, 3]), columns=["one"]) - sns.histplot( - df, y="one" - ) + sns.histplot(df, y="one") plt.show() - sns.histplot( - df, x="one" - ) + sns.histplot(df, x="one") plt.show() diff --git a/tests/outcomes/plot/hist/seaborn/test_data/test.py b/tests/outcomes/plot/hist/seaborn/test_data/test.py index 8699422a..1894467f 100644 --- a/tests/outcomes/plot/hist/seaborn/test_data/test.py +++ b/tests/outcomes/plot/hist/seaborn/test_data/test.py @@ -16,4 +16,6 @@ def test(self): [5, 2, 1, 4, 5, 3], ] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.seaborn) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.seaborn + ) diff --git a/tests/outcomes/plot/hist/seaborn/test_sorting_data/main.py b/tests/outcomes/plot/hist/seaborn/test_sorting_data/main.py index 8535855f..23c0c0d6 100644 --- a/tests/outcomes/plot/hist/seaborn/test_sorting_data/main.py +++ b/tests/outcomes/plot/hist/seaborn/test_sorting_data/main.py @@ -1,23 +1,19 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([5, 4, 3, 2, 1, 3]), columns=['one']) + df = pd.DataFrame(np.array([5, 4, 3, 2, 1, 3]), columns=["one"]) - sns.histplot( - df, y="one" - ) + sns.histplot(df, y="one") plt.show() - sns.histplot( - df, x="one" - ) + sns.histplot(df, x="one") plt.show() diff --git a/tests/outcomes/plot/hist/seaborn/test_sorting_data/test.py b/tests/outcomes/plot/hist/seaborn/test_sorting_data/test.py index 43f1d780..05f5c908 100644 --- a/tests/outcomes/plot/hist/seaborn/test_sorting_data/test.py +++ b/tests/outcomes/plot/hist/seaborn/test_sorting_data/test.py @@ -16,4 +16,6 @@ def test(self): [5, 4, 3, 2, 1, 3], ] - return test_hist_drawing(self.all_figures(), correct_data, DrawingLibrary.seaborn) + return test_hist_drawing( + self.all_figures(), correct_data, DrawingLibrary.seaborn + ) diff --git a/tests/outcomes/plot/hist/test_hist_drawing.py b/tests/outcomes/plot/hist/test_hist_drawing.py index 9df39a5c..5a2ed4cd 100644 --- a/tests/outcomes/plot/hist/test_hist_drawing.py +++ b/tests/outcomes/plot/hist/test_hist_drawing.py @@ -8,21 +8,23 @@ def test_hist_drawing(figures, correct_data, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, hist in enumerate(figures): - if hist.type != 'hist': - return wrong(f'Wrong drawing type {hist.type}. Expected hist') + if hist.type != "hist": + return wrong(f"Wrong drawing type {hist.type}. Expected hist") if hist.library != library_type: - return wrong(f'{hist.library} is wrong library type. Expected {library_type}') + return wrong( + f"{hist.library} is wrong library type. Expected {library_type}" + ) if not isinstance(hist.data.x, np.ndarray): return wrong("The data value should be a ndarray") if not correct_data[i] == hist.data.x.tolist(): - return wrong('Wrong data of the hist graph') + return wrong("Wrong data of the hist graph") return correct() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_ax.py index 391d5f2f..bd04c7c5 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_ax.py @@ -1,17 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - ax.hist(x='one', data=df) + ax.hist(x="one", data=df) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_plt.py index 7d3c15c1..b88e2265 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_data_dataframe_plt.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - plt.hist(x='one', data=df) + plt.hist(x="one", data=df) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_ax.py index fe273e90..cf3569e1 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_ax.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_plt.py index e0e8e2f4..0c4c8916 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_array_plt.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_ax.py index b19fb56b..2486c3e8 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_ax.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) ax.hist(df.one) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_plt.py index 53873517..5b0a218a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_plt.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) plt.hist(df.one) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_ax.py index 2d73b008..74f82a99 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_ax.py @@ -1,17 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - ax.hist(df['one']) + ax.hist(df["one"]) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_plt.py index 25b9969c..56a8c1a0 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_column_string_plt.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - plt.hist(df['one']) + plt.hist(df["one"]) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_ax.py index 28038cc4..6d8f5765 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_ax.py @@ -1,15 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) ax.hist(df) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_plt.py index c2f29dd9..bbf3442e 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_dataframe_plt.py @@ -1,13 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) plt.hist(df) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_ax.py index d132eeb2..f0f06d24 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_plt.py index d6cae2bf..4dc264fa 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_list_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_ax.py index 0288256d..21a22485 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_ax.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_plt.py index 3874228e..50fefb3a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_series_plt.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_ax.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_ax.py index f5be404d..4c94d5a6 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_plt.py b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_plt.py index c8fce022..19cfecae 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/matplotlib_x_tuple_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column.py index edf100e5..d2654924 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) df.one.hist() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot.py index 80a190aa..9ab55a2f 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) df.one.plot.hist() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot_kind.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot_kind.py index 0d103c5f..00a9cb71 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot_kind.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_plot_kind.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.one.plot(kind='hist') + df.one.plot(kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string.py index 4ac136ef..4a72cbc0 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df['one'].hist() + df["one"].hist() plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot.py index c8845f4d..f3f3c275 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df['one'].plot.hist() + df["one"].plot.hist() plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot_kind.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot_kind.py index 2cc8c485..39db441c 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot_kind.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_column_string_plot_kind.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df['one'].plot(kind='hist') + df["one"].plot(kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe.py index c20db505..061beb1a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe.py @@ -1,13 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) df.hist() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_column.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_column.py index 06b971e0..509bb719 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_column.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_column.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.hist(column='one') + df.hist(column="one") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot.py index d353f23c..a4235c1d 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot.py @@ -1,13 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) df.plot.hist() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_column.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_column.py index 1cdc60c8..62504cb5 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_column.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_column.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot.hist(column='one') + df.plot.hist(column="one") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind.py index 02749fbb..baca0808 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind.py @@ -1,15 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), - columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) - df.plot(kind='hist') + df.plot(kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_column.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_column.py index 6e9575a1..b32d4774 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_column.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_column.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot(column='one', kind='hist') + df.plot(column="one", kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py index 4d4e1bd3..73460d96 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_x.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot(x='one', kind='hist') + df.plot(x="one", kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py index cb6747d8..f0269fd8 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_xy.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot(x='two', y='one', kind='hist') + df.plot(x="two", y="one", kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py index 1bcc31d3..52c73ee3 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot(y='one', kind='hist') + df.plot(y="one", kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_x.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_x.py index e8435339..8e0db008 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_x.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_x.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot.hist(x='one') + df.plot.hist(x="one") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_xy.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_xy.py index ff682fdc..a56a28ea 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_xy.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_xy.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot.hist(x='two', y='one') + df.plot.hist(x="two", y="one") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_y.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_y.py index c297330c..29f0e6a4 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_y.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_dataframe_plot_y.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - df.plot.hist(y='one') + df.plot.hist(y="one") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series.py index feb3af3d..0b72efd5 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot.py index c8f798d2..bb1f6f9e 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot_kind.py b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot_kind.py index dc84f770..5ec54cc8 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot_kind.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/pandas_series_plot_kind.py @@ -1,13 +1,13 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return ser = pd.Series(data=np.array([1, 2, 3, 4, 5])) - ser.plot(kind='hist') + ser.plot(kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_array.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_array.py index 956dd21c..f8958ce5 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_array.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_array.py @@ -1,9 +1,8 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import seaborn as sns except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column.py index eb8dd64e..1b3b178e 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column.py @@ -1,14 +1,15 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) sns.histplot(df.one, bins=10) diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column_string.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column_string.py index 6fd53169..606415d2 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column_string.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_column_string.py @@ -1,16 +1,17 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - sns.histplot(df['one'], bins=10) + sns.histplot(df["one"], bins=10) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe.py index 031eb50d..420fa041 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe.py @@ -1,13 +1,13 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=['one']) + df = pd.DataFrame(np.array([1, 2, 3, 4, 5]), columns=["one"]) sns.histplot(df, bins=10) diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_x.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_x.py index a2a4b724..8520f78f 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_x.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_x.py @@ -1,16 +1,17 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - sns.histplot(df, x='one', bins=10) + sns.histplot(df, x="one", bins=10) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_xy.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_xy.py index 9725d1ad..d1d4a35d 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_xy.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_xy.py @@ -1,16 +1,17 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - sns.histplot(df, y='one', x='two', bins=10) + sns.histplot(df, y="one", x="two", bins=10) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_y.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_y.py index 2a3985ae..5600d9ea 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_y.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_dataframe_y.py @@ -1,16 +1,17 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]), columns=["one", "two"] + ) - sns.histplot(df, y='one', bins=10) + sns.histplot(df, y="one", bins=10) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_list.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_list.py index e317fd66..f345870c 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_list.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_list.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_series.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_series.py index 448328f2..0e4f5e0b 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_series.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_series.py @@ -1,9 +1,9 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_tuple.py b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_tuple.py index 43c95016..fc806c4a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_tuple.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/seaborn_tuple.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_simple/test.py b/tests/outcomes/plot/hist/universal_tests/data_simple/test.py index d687b1bb..e2c4caad 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_simple/test.py +++ b/tests/outcomes/plot/hist/universal_tests/data_simple/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestHist(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -19,11 +19,7 @@ def test(self): return wrong("hs-test-python didn't run requested file") universal_test( - file, - 'hist', - [[1, 2, 3, 4, 5]], - [[1, 1, 1, 1, 1]], - self.new_figures() + file, "hist", [[1, 2, 3, 4, 5]], [[1, 1, 1, 1, 1]], self.new_figures() ) return correct() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_ax.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_ax.py index adf47b42..cf96bfce 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_ax.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_plt.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_plt.py index 79ee60e0..ca28f460 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_arrays_plt.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_ax.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_ax.py index 34debdcb..259ed6be 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_ax.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return fig, ax = plt.subplots() - df = pd.DataFrame(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), columns=["one", "two"] + ) ax.hist(df) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_plt.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_plt.py index 4f8620b4..59530e6a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_columns_plt.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), columns=["one", "two"] + ) plt.hist(df) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_ax.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_ax.py index 33f61e16..e3c17fd7 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_plt.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_plt.py index 14a470a8..95eaf016 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_lists_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_ax.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_ax.py index 1a38c262..1892151c 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_ax.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_plt.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_plt.py index 9ce49f23..b9ef2c42 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_plt.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/matplotlib_x_tuples_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_hist_by.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_hist_by.py index e422b7fc..0128a982 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_hist_by.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_hist_by.py @@ -1,16 +1,30 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2], ]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - df.one.hist(by=df['two']) + df.one.hist(by=df["two"]) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_string_hist_by.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_string_hist_by.py index df2ac577..813f50df 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_string_hist_by.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_column_string_hist_by.py @@ -1,16 +1,30 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2], ]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - df['one'].hist(by=df['two']) + df["one"].hist(by=df["two"]) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist.py index 32dd38e1..419225db 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), columns=["one", "two"] + ) df.hist() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_dataframe.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_dataframe.py index e5ebe465..c5ee17c4 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_dataframe.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_dataframe.py @@ -1,16 +1,30 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2], ]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - df.hist(column='one', by=df['two']) + df.hist(column="one", by=df["two"]) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_str.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_str.py index 4da12a86..13fbf95e 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_str.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_hist_by_str.py @@ -1,16 +1,30 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2], ]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - df.hist(column='one', by='two') + df.hist(column="one", by="two") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist.py index 8cdd99b6..436b9818 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist.py @@ -1,13 +1,14 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), columns=["one", "two"] + ) df.plot.hist() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist_by.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist_by.py index 783fadd4..87a73624 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist_by.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_hist_by.py @@ -1,16 +1,30 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2], ]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - df.plot.hist(column='one', by='two') + df.plot.hist(column="one", by="two") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist.py index b0f6cb1c..1ef508c1 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist.py @@ -1,15 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), columns=["one", "two"] + ) - df.plot(kind='hist') + df.plot(kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist_by.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist_by.py index 94e9063a..61d8c2cc 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist_by.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_dataframe_plot_kind_hist_by.py @@ -1,16 +1,30 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2], ]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - df.plot(column='one', by='two', kind='hist') + df.plot(column="one", by="two", kind="hist") plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_series_hist_by.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_series_hist_by.py index b2bf7de6..047b59fe 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_series_hist_by.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/pandas_series_hist_by.py @@ -1,8 +1,8 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_array.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_array.py index ccc2f7ff..90dfd411 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_array.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_array.py @@ -1,9 +1,8 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import seaborn as sns except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe.py index 98061ec9..65da3e26 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe.py @@ -1,14 +1,15 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array([[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]), columns=["one", "two"] + ) sns.histplot(df, bins=10) diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe_hue.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe_hue.py index 456938cb..211e68d3 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe_hue.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_dataframe_hue.py @@ -1,17 +1,31 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd import numpy as np + import pandas as pd + import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 1], [2, 2], [3, 1], [4, 2], [5, 1], - [6, 2], [7, 1], [8, 2], [9, 1], [10, 2],]), - columns=['one', 'two']) + df = pd.DataFrame( + np.array( + [ + [1, 1], + [2, 2], + [3, 1], + [4, 2], + [5, 1], + [6, 2], + [7, 1], + [8, 2], + [9, 1], + [10, 2], + ] + ), + columns=["one", "two"], + ) - sns.histplot(df, x='one', hue='two', bins=10) + sns.histplot(df, x="one", hue="two", bins=10) plt.show() diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_list.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_list.py index df656b8b..2c60b326 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_list.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_list.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_tuple.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_tuple.py index 3f0d6e80..487d6f7a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_tuple.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/seaborn_histplot_tuple.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/hist/universal_tests/data_two_pics/test.py b/tests/outcomes/plot/hist/universal_tests/data_two_pics/test.py index 8e95e4cd..e197f52a 100644 --- a/tests/outcomes/plot/hist/universal_tests/data_two_pics/test.py +++ b/tests/outcomes/plot/hist/universal_tests/data_two_pics/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestHist(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -20,10 +20,10 @@ def test(self): universal_test( file, - 'hist', + "hist", [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]], [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1]], - self.new_figures() + self.new_figures(), ) return correct() diff --git a/tests/outcomes/plot/line/matplotlib/main.py b/tests/outcomes/plot/line/matplotlib/main.py index 9552271d..46fae684 100644 --- a/tests/outcomes/plot/line/matplotlib/main.py +++ b/tests/outcomes/plot/line/matplotlib/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/line/matplotlib/test.py b/tests/outcomes/plot/line/matplotlib/test.py index 56b90657..b308bfe8 100644 --- a/tests/outcomes/plot/line/matplotlib/test.py +++ b/tests/outcomes/plot/line/matplotlib/test.py @@ -14,7 +14,9 @@ def test(self): correct_data = [ [[1, 5], [2, 8]], [[1, 5], [2, 8]], - [[1, 0], [5, 1], [7, 2], [8, 3]] + [[1, 0], [5, 1], [7, 2], [8, 3]], ] - return test_line_drawing(self.all_figures(), 3, correct_data, DrawingLibrary.matplotlib) + return test_line_drawing( + self.all_figures(), 3, correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/line/pandas/main.py b/tests/outcomes/plot/line/pandas/main.py index 3caa9157..beda67c8 100644 --- a/tests/outcomes/plot/line/pandas/main.py +++ b/tests/outcomes/plot/line/pandas/main.py @@ -1,19 +1,15 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import pandas as pd except ModuleNotFoundError: return s = pd.Series([1, 3, 2]) s.plot.line() - s.plot(kind='line') + s.plot(kind="line") - df = pd.DataFrame({ - 'a': [1, 3, 2], - 'b': [1, 3, 2] - }, index=[2, 4, 6]) + df = pd.DataFrame({"a": [1, 3, 2], "b": [1, 3, 2]}, index=[2, 4, 6]) df.plot.line() plt.show() diff --git a/tests/outcomes/plot/line/pandas/test.py b/tests/outcomes/plot/line/pandas/test.py index b28d78b0..e5e48279 100644 --- a/tests/outcomes/plot/line/pandas/test.py +++ b/tests/outcomes/plot/line/pandas/test.py @@ -15,7 +15,9 @@ def test(self): [[0, 1], [1, 3], [2, 2]], [[0, 1], [1, 3], [2, 2]], [[2, 1], [4, 3], [6, 2]], - [[2, 1], [4, 3], [6, 2]] + [[2, 1], [4, 3], [6, 2]], ] - return test_line_drawing(self.all_figures(), 4, correct_data, DrawingLibrary.pandas) + return test_line_drawing( + self.all_figures(), 4, correct_data, DrawingLibrary.pandas + ) diff --git a/tests/outcomes/plot/line/seaborn/main.py b/tests/outcomes/plot/line/seaborn/main.py index 7b9f5973..1af34349 100644 --- a/tests/outcomes/plot/line/seaborn/main.py +++ b/tests/outcomes/plot/line/seaborn/main.py @@ -1,15 +1,11 @@ def plot(): try: import pandas as pd - import numpy as np import seaborn as sns except ModuleNotFoundError: return - df = pd.DataFrame({ - 'a': [1, 3, 2], - 'b': [1, 3, 2] - }, index=[2, 4, 6]) + df = pd.DataFrame({"a": [1, 3, 2], "b": [1, 3, 2]}, index=[2, 4, 6]) sns.lineplot(data=df, x="a", y="b") sns.lineplot(data=df) diff --git a/tests/outcomes/plot/line/seaborn/test.py b/tests/outcomes/plot/line/seaborn/test.py index 0e1c5a3f..00b6852b 100644 --- a/tests/outcomes/plot/line/seaborn/test.py +++ b/tests/outcomes/plot/line/seaborn/test.py @@ -14,7 +14,9 @@ def test(self): correct_data = [ [[1, 1], [3, 3], [2, 2]], [[2, 1], [4, 3], [6, 2]], - [[2, 1], [4, 3], [6, 2]] + [[2, 1], [4, 3], [6, 2]], ] - return test_line_drawing(self.all_figures(), 3, correct_data, DrawingLibrary.seaborn) + return test_line_drawing( + self.all_figures(), 3, correct_data, DrawingLibrary.seaborn + ) diff --git a/tests/outcomes/plot/line/test_line_drawing.py b/tests/outcomes/plot/line/test_line_drawing.py index ecda23ef..19cd6268 100644 --- a/tests/outcomes/plot/line/test_line_drawing.py +++ b/tests/outcomes/plot/line/test_line_drawing.py @@ -6,21 +6,23 @@ def test_line_drawing(figures, correct_plot_count, correct_data, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, line in enumerate(figures): - if line.type != 'line': - return wrong(f'Wrong drawing type {line.type}. Expected line') + if line.type != "line": + return wrong(f"Wrong drawing type {line.type}. Expected line") if line.library != library_type: - return wrong(f'{line.library} is wrong library type. Expected {library_type}') + return wrong( + f"{line.library} is wrong library type. Expected {library_type}" + ) if not isinstance(line.data, np.ndarray): return wrong("The data value should be a ndarray") if not np.array_equal(correct_data[i], line.data.data): - return wrong('Wrong data of the line graph') + return wrong("Wrong data of the line graph") return correct() diff --git a/tests/outcomes/plot/lm/seaborn/main.py b/tests/outcomes/plot/lm/seaborn/main.py index d970f4c5..3e500744 100644 --- a/tests/outcomes/plot/lm/seaborn/main.py +++ b/tests/outcomes/plot/lm/seaborn/main.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/lm/test_lm_drawing.py b/tests/outcomes/plot/lm/test_lm_drawing.py index 7afc0712..a5432dae 100644 --- a/tests/outcomes/plot/lm/test_lm_drawing.py +++ b/tests/outcomes/plot/lm/test_lm_drawing.py @@ -4,16 +4,16 @@ def test_lm_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, lm in enumerate(figures): - if lm.type != 'lm': - return wrong(f'Wrong drawing type {lm.type}. Expected lm') + if lm.type != "lm": + return wrong(f"Wrong drawing type {lm.type}. Expected lm") if lm.library != library_type: - return wrong(f'{lm.library} is wrong library type. Expected {library_type}') + return wrong(f"{lm.library} is wrong library type. Expected {library_type}") if lm.data is not None: return wrong("The data value should be None") diff --git a/tests/outcomes/plot/pie/test_pie_drawing.py b/tests/outcomes/plot/pie/test_pie_drawing.py index fdb259a7..3aa0b316 100644 --- a/tests/outcomes/plot/pie/test_pie_drawing.py +++ b/tests/outcomes/plot/pie/test_pie_drawing.py @@ -6,24 +6,26 @@ def test_pie_drawing(figures, correct_plot_count, correct_data, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, pie in enumerate(figures): - if pie.type != 'pie': - return wrong(f'Wrong drawing type {pie.type}. Expected pie') + if pie.type != "pie": + return wrong(f"Wrong drawing type {pie.type}. Expected pie") if pie.library != library_type: - return wrong(f'{pie.library} is wrong library type. Expected {library_type}') + return wrong( + f"{pie.library} is wrong library type. Expected {library_type}" + ) if not isinstance(pie.data.y, np.ndarray): return wrong("The data value should be a ndarray") if not np.array_equal(correct_data[i][:, 0], pie.data.x): - return wrong('Wrong x data of the pie graph') + return wrong("Wrong x data of the pie graph") if not np.array_equal(correct_data[i][:, 1], pie.data.y): - return wrong('Wrong y data of the pie graph') + return wrong("Wrong y data of the pie graph") return correct() diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_ax.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_ax.py index a004d42d..dd2ee72c 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_ax.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_plt.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_plt.py index fbf3d3aa..808f173e 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_plt.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_array_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_ax.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_ax.py index 8afe5f7b..54deb550 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_ax.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_ax.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_plt.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_plt.py index 35528765..463e56fc 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_plt.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_nparray_plt.py @@ -1,8 +1,7 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_ax.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_ax.py index 61dd2941..6b3bb5de 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_ax.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_ax.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_plt.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_plt.py index 9a9cde29..34da5f70 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_plt.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/matplotlib_y_tuple_plt.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/pie/universal_tests/data_no_label/test.py b/tests/outcomes/plot/pie/universal_tests/data_no_label/test.py index cd55df16..b8b16c61 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_no_label/test.py +++ b/tests/outcomes/plot/pie/universal_tests/data_no_label/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -18,12 +18,6 @@ def test(self): if str(program) != file: return wrong("hs-test-python didn't run requested file") - universal_test( - file, - 'pie', - [['', '', '']], - [[1, 2, 3]], - self.new_figures() - ) + universal_test(file, "pie", [["", "", ""]], [[1, 2, 3]], self.new_figures()) return correct() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_ax.py b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_ax.py index cb06126e..7c4da531 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_ax.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_ax.py @@ -1,14 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return fig, ax = plt.subplots(figsize=(1, 2)) - ax.pie([1, 2, 3], labels=['Mercury', 'Venus', 'Earth']) + ax.pie([1, 2, 3], labels=["Mercury", "Venus", "Earth"]) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_plt.py b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_plt.py index 49debfef..856e55ff 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_plt.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_array_plt.py @@ -1,11 +1,9 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return - plt.pie([1, 2, 3], labels=['Mercury', 'Venus', 'Earth']) + plt.pie([1, 2, 3], labels=["Mercury", "Venus", "Earth"]) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_ax.py b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_ax.py index 32cae55a..7aabd0b0 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_ax.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_ax.py @@ -1,14 +1,13 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return fig, ax = plt.subplots(figsize=(5, 5)) - ax.pie(np.array([1, 2, 3]), labels=['Mercury', 'Venus', 'Earth']) + ax.pie(np.array([1, 2, 3]), labels=["Mercury", "Venus", "Earth"]) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_plt.py b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_plt.py index cbcc2dd0..0c323ec6 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_plt.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_nparray_plt.py @@ -1,12 +1,11 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np except ModuleNotFoundError: return - plt.pie(np.array([1, 2, 3]), labels=['Mercury', 'Venus', 'Earth']) + plt.pie(np.array([1, 2, 3]), labels=["Mercury", "Venus", "Earth"]) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_ax.py b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_ax.py index f8e310ca..b61bff55 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_ax.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_ax.py @@ -1,14 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return fig, ax = plt.subplots(figsize=(5, 5)) - ax.pie((1, 2, 3), labels=['Mercury', 'Venus', 'Earth']) + ax.pie((1, 2, 3), labels=["Mercury", "Venus", "Earth"]) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_plt.py b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_plt.py index 45a86b3d..6e2a6188 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_plt.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/matplotlib_y_tuple_plt.py @@ -1,12 +1,10 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return - plt.pie((1, 2, 3), labels=['Mercury', 'Venus', 'Earth']) + plt.pie((1, 2, 3), labels=["Mercury", "Venus", "Earth"]) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py index ca1f8766..dfd94fcd 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_kind_y.py @@ -1,15 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5]]), - columns=['one', 'two', 'three'], index=['Mercury', 'Venus', 'Earth']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5]]), + columns=["one", "two", "three"], + index=["Mercury", "Venus", "Earth"], + ) - df.plot(y='one', kind='pie') + df.plot(y="one", kind="pie") plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_y.py b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_y.py index cab28c89..ad2b56ed 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_y.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_dataframe_plot_y.py @@ -1,15 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5]]), - columns=['one', 'two', 'three'], index=['Mercury', 'Venus', 'Earth']) + df = pd.DataFrame( + np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5]]), + columns=["one", "two", "three"], + index=["Mercury", "Venus", "Earth"], + ) - df.plot.pie(y='one') + df.plot.pie(y="one") plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_kind_y.py b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_kind_y.py index abd4b5f4..b98104c7 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_kind_y.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_kind_y.py @@ -1,13 +1,13 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - ser = pd.Series(data=np.array([1, 2, 3]), index=['Mercury', 'Venus', 'Earth']) - ser.plot(kind='pie') + ser = pd.Series(data=np.array([1, 2, 3]), index=["Mercury", "Venus", "Earth"]) + ser.plot(kind="pie") plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_y.py b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_y.py index 4241e13c..048d3117 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_y.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/pandas_series_plot_y.py @@ -1,12 +1,12 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - ser = pd.Series(data=np.array([1, 2, 3]), index=['Mercury', 'Venus', 'Earth']) + ser = pd.Series(data=np.array([1, 2, 3]), index=["Mercury", "Venus", "Earth"]) ser.plot.pie() plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_simple/test.py b/tests/outcomes/plot/pie/universal_tests/data_simple/test.py index 3ec5ecc0..e9f0b4bd 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_simple/test.py +++ b/tests/outcomes/plot/pie/universal_tests/data_simple/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -20,10 +20,10 @@ def test(self): universal_test( file, - 'pie', - [['Mercury', 'Venus', 'Earth']], + "pie", + [["Mercury", "Venus", "Earth"]], [[1, 2, 3]], - self.new_figures() + self.new_figures(), ) return correct() diff --git a/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot.py b/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot.py index 4215ede7..42d23bbe 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot.py +++ b/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot.py @@ -1,13 +1,16 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4]]), - columns=['one', 'two'], index=['Mercury', 'Venus', 'Earth']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4]]), + columns=["one", "two"], + index=["Mercury", "Venus", "Earth"], + ) df.plot.pie(subplots=True) diff --git a/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot_kind.py b/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot_kind.py index 7c1015bd..cdb3762e 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot_kind.py +++ b/tests/outcomes/plot/pie/universal_tests/data_two_pics/pandas_dataframe_plot_kind.py @@ -1,15 +1,18 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame(np.array([[1, 2], [2, 3], [3, 4]]), - columns=['one', 'two'], index=['Mercury', 'Venus', 'Earth']) + df = pd.DataFrame( + np.array([[1, 2], [2, 3], [3, 4]]), + columns=["one", "two"], + index=["Mercury", "Venus", "Earth"], + ) - df.plot(kind='pie', subplots=True) + df.plot(kind="pie", subplots=True) plt.show() diff --git a/tests/outcomes/plot/pie/universal_tests/data_two_pics/test.py b/tests/outcomes/plot/pie/universal_tests/data_two_pics/test.py index c9ddd74b..3b5352cb 100644 --- a/tests/outcomes/plot/pie/universal_tests/data_two_pics/test.py +++ b/tests/outcomes/plot/pie/universal_tests/data_two_pics/test.py @@ -1,6 +1,6 @@ import os -from hstest import correct, TestedProgram, wrong +from hstest import TestedProgram, correct, wrong from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from tests.outcomes.plot.universal_test import universal_test @@ -9,7 +9,7 @@ class TestBar(PlottingTest): @dynamic_test def test(self): - files = [i for i in os.listdir() if i != 'test.py' and i.endswith('.py')] + files = [i for i in os.listdir() if i != "test.py" and i.endswith(".py")] for file in files: program = TestedProgram(file) @@ -20,12 +20,10 @@ def test(self): universal_test( file, - 'pie', - [['Mercury', 'Venus', 'Earth'], - ['Mercury', 'Venus', 'Earth']], - [[1, 2, 3], - [2, 3, 4]], - self.new_figures() + "pie", + [["Mercury", "Venus", "Earth"], ["Mercury", "Venus", "Earth"]], + [[1, 2, 3], [2, 3, 4]], + self.new_figures(), ) return correct() diff --git a/tests/outcomes/plot/scatter/matplotlib/main.py b/tests/outcomes/plot/scatter/matplotlib/main.py index 348e17d6..c5879e81 100644 --- a/tests/outcomes/plot/scatter/matplotlib/main.py +++ b/tests/outcomes/plot/scatter/matplotlib/main.py @@ -1,7 +1,5 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/scatter/matplotlib/test.py b/tests/outcomes/plot/scatter/matplotlib/test.py index 970893ff..3a4c3c0d 100644 --- a/tests/outcomes/plot/scatter/matplotlib/test.py +++ b/tests/outcomes/plot/scatter/matplotlib/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.scatter.test_scatter_drawing import test_scatter_drawing +from tests.outcomes.plot.scatter.test_scatter_drawing import \ + test_scatter_drawing class TestMatplotlibScatter(PlottingTest): @@ -11,9 +12,8 @@ def test(self): program = TestedProgram() program.start() - correct_data = [ - [[1, 2], [2, 6]], - [[1, 2], [2, 6]] - ] + correct_data = [[[1, 2], [2, 6]], [[1, 2], [2, 6]]] - return test_scatter_drawing(self.all_figures(), 2, correct_data, DrawingLibrary.matplotlib) + return test_scatter_drawing( + self.all_figures(), 2, correct_data, DrawingLibrary.matplotlib + ) diff --git a/tests/outcomes/plot/scatter/pandas/main.py b/tests/outcomes/plot/scatter/pandas/main.py index 10b99bfd..8742570f 100644 --- a/tests/outcomes/plot/scatter/pandas/main.py +++ b/tests/outcomes/plot/scatter/pandas/main.py @@ -1,21 +1,15 @@ def plot(): try: - import pandas as pd - import numpy as np import matplotlib.pyplot as plt + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame([[1, 2], [2, 6]], - columns=['length', 'width']) - df.plot.scatter(x='length', - y='width', - c='DarkBlue') + df = pd.DataFrame([[1, 2], [2, 6]], columns=["length", "width"]) + df.plot.scatter(x="length", y="width", c="DarkBlue") - df.plot(kind='scatter', x='length', - y='width', - c='DarkBlue') + df.plot(kind="scatter", x="length", y="width", c="DarkBlue") plt.show() diff --git a/tests/outcomes/plot/scatter/pandas/test.py b/tests/outcomes/plot/scatter/pandas/test.py index 2ec09462..b2ece95a 100644 --- a/tests/outcomes/plot/scatter/pandas/test.py +++ b/tests/outcomes/plot/scatter/pandas/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.scatter.test_scatter_drawing import test_scatter_drawing +from tests.outcomes.plot.scatter.test_scatter_drawing import \ + test_scatter_drawing class TestPandasScatter(PlottingTest): @@ -11,9 +12,8 @@ def test(self): program = TestedProgram() program.start() - correct_data = [ - [[1, 2], [2, 6]], - [[1, 2], [2, 6]] - ] + correct_data = [[[1, 2], [2, 6]], [[1, 2], [2, 6]]] - return test_scatter_drawing(self.all_figures(), 2, correct_data, DrawingLibrary.pandas) + return test_scatter_drawing( + self.all_figures(), 2, correct_data, DrawingLibrary.pandas + ) diff --git a/tests/outcomes/plot/scatter/seaborn/main.py b/tests/outcomes/plot/scatter/seaborn/main.py index 020ef2f6..942d8f14 100644 --- a/tests/outcomes/plot/scatter/seaborn/main.py +++ b/tests/outcomes/plot/scatter/seaborn/main.py @@ -1,18 +1,16 @@ def plot(): try: + import matplotlib.pyplot as plt import pandas as pd - import numpy as np import seaborn as sns - import matplotlib.pyplot as plt except ModuleNotFoundError: return - df = pd.DataFrame([[1, 2, 3], [2, 6, 4]], - columns=['length', 'width', 'test']) - sns.scatterplot(data=df, x='length', y='width') + df = pd.DataFrame([[1, 2, 3], [2, 6, 4]], columns=["length", "width", "test"]) + sns.scatterplot(data=df, x="length", y="width") sns.scatterplot(data=df) - sns.scatterplot(data=df, x='length') - sns.scatterplot(data=df, y='length') + sns.scatterplot(data=df, x="length") + sns.scatterplot(data=df, y="length") plt.show() diff --git a/tests/outcomes/plot/scatter/seaborn/test.py b/tests/outcomes/plot/scatter/seaborn/test.py index 5549beee..d3b7c1d4 100644 --- a/tests/outcomes/plot/scatter/seaborn/test.py +++ b/tests/outcomes/plot/scatter/seaborn/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.scatter.test_scatter_drawing import test_scatter_drawing +from tests.outcomes.plot.scatter.test_scatter_drawing import \ + test_scatter_drawing class TestSeabornScatter(PlottingTest): @@ -15,7 +16,9 @@ def test(self): [[1, 2], [2, 6]], [[0, 1], [1, 2]], [[0, 2], [1, 6]], - [[0, 3], [1, 4]] + [[0, 3], [1, 4]], ] - return test_scatter_drawing(self.all_figures(), 4, correct_data, DrawingLibrary.seaborn) + return test_scatter_drawing( + self.all_figures(), 4, correct_data, DrawingLibrary.seaborn + ) diff --git a/tests/outcomes/plot/scatter/test_scatter_drawing.py b/tests/outcomes/plot/scatter/test_scatter_drawing.py index 6c80f243..bffd5e96 100644 --- a/tests/outcomes/plot/scatter/test_scatter_drawing.py +++ b/tests/outcomes/plot/scatter/test_scatter_drawing.py @@ -6,21 +6,23 @@ def test_scatter_drawing(figures, correct_plot_count, correct_data, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, scatter in enumerate(figures): - if scatter.type != 'scatter': - return wrong(f'Wrong drawing type {scatter.type}. Expected scatter') + if scatter.type != "scatter": + return wrong(f"Wrong drawing type {scatter.type}. Expected scatter") if scatter.library != library_type: - return wrong(f'{scatter.library} is wrong library type. Expected {library_type}') + return wrong( + f"{scatter.library} is wrong library type. Expected {library_type}" + ) if not isinstance(scatter.data, np.ndarray): return wrong("The data value should be a ndarray") if not np.array_equal(correct_data[i], scatter.data.data): - return wrong('Wrong data of the scatter graph') + return wrong("Wrong data of the scatter graph") return correct() diff --git a/tests/outcomes/plot/test_matplotlib/test_revert/main.py b/tests/outcomes/plot/test_matplotlib/test_revert/main.py index 76886848..f3063f8e 100644 --- a/tests/outcomes/plot/test_matplotlib/test_revert/main.py +++ b/tests/outcomes/plot/test_matplotlib/test_revert/main.py @@ -27,16 +27,18 @@ def plot(): plt.violinplot([1, 2, 4]) ax.violinplot([1, 2, 5]) - smile = [[0, 0, 1, 1, 1, 1, 1, 1, 0, 0], - [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], - [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], - [1, 0, 0, 1, 0, 0, 1, 0, 0, 1], - [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], - [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], - [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], - [1, 0, 0, 1, 1, 1, 1, 0, 0, 1], - [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], - [0, 0, 1, 1, 1, 1, 1, 1, 0, 0]] + smile = [ + [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], + [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], + [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], + [1, 0, 0, 1, 0, 0, 1, 0, 0, 1], + [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], + [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], + [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], + [1, 0, 0, 1, 1, 1, 1, 0, 0, 1], + [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], + [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], + ] plt.imshow(smile) ax.imshow(smile) diff --git a/tests/outcomes/plot/test_matplotlib/test_revert/test.py b/tests/outcomes/plot/test_matplotlib/test_revert/test.py index 72d3d5a9..509c11f1 100644 --- a/tests/outcomes/plot/test_matplotlib/test_revert/test.py +++ b/tests/outcomes/plot/test_matplotlib/test_revert/test.py @@ -12,7 +12,7 @@ def test(self): MatplotlibHandler.revert_plots() backend = matplotlib.get_backend() - matplotlib.use('Agg') + matplotlib.use("Agg") program = TestedProgram() program.start() @@ -21,8 +21,8 @@ def test(self): if len(self.all_figures()) != 0: return wrong( - f'Expected 0 plots to be plotted using matplotlib library, ' - f'found {len(self.all_figures())}' + f"Expected 0 plots to be plotted using matplotlib library, " + f"found {len(self.all_figures())}" ) return correct() diff --git a/tests/outcomes/plot/test_pandas/test_revert/main.py b/tests/outcomes/plot/test_pandas/test_revert/main.py index deb94885..26752d4b 100644 --- a/tests/outcomes/plot/test_pandas/test_revert/main.py +++ b/tests/outcomes/plot/test_pandas/test_revert/main.py @@ -1,77 +1,73 @@ def plot(): try: - import pandas as pd import numpy as np + import pandas as pd except ModuleNotFoundError: return - df = pd.DataFrame({ - 'sales': [3, 2, 3, 9, 10, 6], - 'signups': [5, 5, 6, 12, 14, 13], - 'visits': [20, 42, 28, 62, 81, 50], - }, index=pd.date_range(start='2018/01/01', end='2018/07/01', - freq='M')) + df = pd.DataFrame( + { + "sales": [3, 2, 3, 9, 10, 6], + "signups": [5, 5, 6, 12, 14, 13], + "visits": [20, 42, 28, 62, 81, 50], + }, + index=pd.date_range(start="2018/01/01", end="2018/07/01", freq="M"), + ) df.plot.area() - df.plot(kind='area') + df.plot(kind="area") - df = pd.DataFrame({'lab': ['A', 'B', 'C'], 'val': [10, 30, 20]}) - df.plot.bar(x='lab', y='val', rot=0) - df.plot(kind='bar', x='lab', y='val', rot=0) + df = pd.DataFrame({"lab": ["A", "B", "C"], "val": [10, 30, 20]}) + df.plot.bar(x="lab", y="val", rot=0) + df.plot(kind="bar", x="lab", y="val", rot=0) - df = pd.DataFrame({'lab': ['A', 'B', 'C'], 'val': [10, 30, 20]}) - df.plot.barh(x='lab', y='val') - df.plot(kind='barh', x='lab', y='val') + df = pd.DataFrame({"lab": ["A", "B", "C"], "val": [10, 30, 20]}) + df.plot.barh(x="lab", y="val") + df.plot(kind="barh", x="lab", y="val") data = np.random.randn(25, 4) - df = pd.DataFrame(data, columns=list('ABCD')) + df = pd.DataFrame(data, columns=list("ABCD")) df.plot.box() - df.plot(kind='box') + df.plot(kind="box") s = pd.Series([1, 2, 2.5, 3, 3.5, 4, 5]) s.plot.kde() - s.plot(kind='kde') + s.plot(kind="kde") n = 10000 - df = pd.DataFrame({'x': np.random.randn(n), - 'y': np.random.randn(n)}) - df.plot.hexbin(x='x', y='y', gridsize=20) - df.plot(kind='hexbin', x='x', y='y', gridsize=20) + df = pd.DataFrame({"x": np.random.randn(n), "y": np.random.randn(n)}) + df.plot.hexbin(x="x", y="y", gridsize=20) + df.plot(kind="hexbin", x="x", y="y", gridsize=20) - df = pd.DataFrame( - np.random.randint(1, 7, 6000), - columns=['one']) - df['two'] = df['one'] + np.random.randint(1, 7, 6000) + df = pd.DataFrame(np.random.randint(1, 7, 6000), columns=["one"]) + df["two"] = df["one"] + np.random.randint(1, 7, 6000) df.plot.hist(bins=12, alpha=0.5) - df.plot(kind='hist', bins=12, alpha=0.5) + df.plot(kind="hist", bins=12, alpha=0.5) s = pd.Series([1, 3, 2]) s.plot.line() - s.plot(kind='line') + s.plot(kind="line") - df = pd.DataFrame({'mass': [0.330, 4.87, 5.97], - 'radius': [2439.7, 6051.8, 6378.1]}, - index=['Mercury', 'Venus', 'Earth']) - df.plot.pie(y='mass', figsize=(5, 5)) - df.plot(kind='pie', y='mass', figsize=(5, 5)) + df = pd.DataFrame( + {"mass": [0.330, 4.87, 5.97], "radius": [2439.7, 6051.8, 6378.1]}, + index=["Mercury", "Venus", "Earth"], + ) + df.plot.pie(y="mass", figsize=(5, 5)) + df.plot(kind="pie", y="mass", figsize=(5, 5)) - df = pd.DataFrame([[5.1, 3.5, 0], [4.9, 3.0, 0], [7.0, 3.2, 1], - [6.4, 3.2, 1], [5.9, 3.0, 2]], - columns=['length', 'width', 'species']) - df.plot.scatter(x='length', - y='width', - c='DarkBlue') + df = pd.DataFrame( + [[5.1, 3.5, 0], [4.9, 3.0, 0], [7.0, 3.2, 1], [6.4, 3.2, 1], [5.9, 3.0, 2]], + columns=["length", "width", "species"], + ) + df.plot.scatter(x="length", y="width", c="DarkBlue") - df.plot(kind='scatter', x='length', - y='width', - c='DarkBlue') + df.plot(kind="scatter", x="length", y="width", c="DarkBlue") np.random.seed(1234) - df = pd.DataFrame(np.random.randn(10, 4), - columns=['Col1', 'Col2', 'Col3', 'Col4']) - df.hist(column=['Col1', 'Col2', 'Col3']) + df = pd.DataFrame(np.random.randn(10, 4), columns=["Col1", "Col2", "Col3", "Col4"]) + df.hist(column=["Col1", "Col2", "Col3"]) - d = {'a': 1, 'b': 2, 'c': 3} - ser = pd.Series(data=d, index=['a', 'b', 'c']) + d = {"a": 1, "b": 2, "c": 3} + ser = pd.Series(data=d, index=["a", "b", "c"]) ser.hist() import matplotlib.pyplot as plt diff --git a/tests/outcomes/plot/test_pandas/test_revert/test.py b/tests/outcomes/plot/test_pandas/test_revert/test.py index fa16e09e..c989668e 100644 --- a/tests/outcomes/plot/test_pandas/test_revert/test.py +++ b/tests/outcomes/plot/test_pandas/test_revert/test.py @@ -12,7 +12,7 @@ def test(self): PandasHandler.revert_plots() backend = matplotlib.get_backend() - matplotlib.use('Agg') + matplotlib.use("Agg") program = TestedProgram() program.start() @@ -21,8 +21,8 @@ def test(self): if len(self.all_figures()) != 0: return wrong( - f'Expected 0 plots to be plotted using matplotlib library, ' - f'found {len(self.all_figures())}' + f"Expected 0 plots to be plotted using matplotlib library, " + f"found {len(self.all_figures())}" ) return correct() diff --git a/tests/outcomes/plot/test_seaborn/test_revert/main.py b/tests/outcomes/plot/test_seaborn/test_revert/main.py index 0528854b..72bc8980 100644 --- a/tests/outcomes/plot/test_seaborn/test_revert/main.py +++ b/tests/outcomes/plot/test_seaborn/test_revert/main.py @@ -1,8 +1,8 @@ def plot(): try: - import seaborn as sns - import numpy as np import matplotlib.pyplot as plt + import numpy as np + import seaborn as sns except ModuleNotFoundError: return @@ -10,8 +10,13 @@ def plot(): df = sns.load_dataset("penguins") sns.displot( - df, x="flipper_length_mm", col="species", row="sex", - binwidth=3, height=3, facet_kws=dict(margin_titles=True), + df, + x="flipper_length_mm", + col="species", + row="sex", + binwidth=3, + height=3, + facet_kws=dict(margin_titles=True), ) # sns.histplot( @@ -23,25 +28,29 @@ def plot(): sns.scatterplot(data=df, x="flipper_length_mm", y="flipper_length_mm") sns.catplot( - data=df, kind="bar", - x="species", y="body_mass_g", hue="sex", - ci="sd", palette="dark", alpha=.6, height=6 + data=df, + kind="bar", + x="species", + y="body_mass_g", + hue="sex", + ci="sd", + palette="dark", + alpha=0.6, + height=6, ) x = np.array(list("ABCDEFGHIJ")) y1 = np.arange(1, 11) sns.barplot(x=x, y=y1, palette="rocket", ax=ax) - sns.violinplot(data=df, palette="Set3", bw=.2, cut=1, linewidth=1) + sns.violinplot(data=df, palette="Set3", bw=0.2, cut=1, linewidth=1) flights_long = sns.load_dataset("flights") flights = flights_long.pivot("month", "year", "passengers") - sns.heatmap(flights, annot=True, fmt="d", linewidths=.5, ax=ax) + sns.heatmap(flights, annot=True, fmt="d", linewidths=0.5, ax=ax) tips = sns.load_dataset("tips") - sns.boxplot(x="day", y="total_bill", - hue="smoker", palette=["m", "g"], - data=tips) + sns.boxplot(x="day", y="total_bill", hue="smoker", palette=["m", "g"], data=tips) sns.despine(offset=10, trim=True) import matplotlib.pyplot as plt diff --git a/tests/outcomes/plot/test_seaborn/test_revert/test.py b/tests/outcomes/plot/test_seaborn/test_revert/test.py index da8748e4..43bb5fb6 100644 --- a/tests/outcomes/plot/test_seaborn/test_revert/test.py +++ b/tests/outcomes/plot/test_seaborn/test_revert/test.py @@ -12,7 +12,7 @@ def test(self): SeabornHandler.revert_plots() backend = matplotlib.get_backend() - matplotlib.use('Agg') + matplotlib.use("Agg") program = TestedProgram() program.start() @@ -23,8 +23,8 @@ def test(self): if len(self.all_figures()) != 0: return wrong( - f'Expected 0 plots to be plotted using matplotlib library, ' - f'found {len(self.all_figures())}' + f"Expected 0 plots to be plotted using matplotlib library, " + f"found {len(self.all_figures())}" ) return correct() diff --git a/tests/outcomes/plot/universal_test.py b/tests/outcomes/plot/universal_test.py index cfe73b27..44b043a0 100644 --- a/tests/outcomes/plot/universal_test.py +++ b/tests/outcomes/plot/universal_test.py @@ -3,7 +3,7 @@ def universal_test(file, plot_type, correct_data_x, correct_data_y, figures): if len(correct_data_x) != len(correct_data_y): - raise WrongAnswer('Correct answers should be of the same length') + raise WrongAnswer("Correct answers should be of the same length") if len(figures) != len(correct_data_x): raise WrongAnswer( @@ -23,16 +23,12 @@ def universal_test(file, plot_type, correct_data_x, correct_data_y, figures): if corr_x != found_data_x: raise WrongAnswer( - f"{file}\n\n" - f"Found data: {found_data_x}\n" - f"Right data: {corr_x}" + f"{file}\n\n" f"Found data: {found_data_x}\n" f"Right data: {corr_x}" ) if corr_y != found_data_y: raise WrongAnswer( - f"{file}\n\n" - f"Found data: {found_data_y}\n" - f"Right data: {corr_y}" + f"{file}\n\n" f"Found data: {found_data_y}\n" f"Right data: {corr_y}" ) - print(plot_type.capitalize(), file, 'OK') + print(plot_type.capitalize(), file, "OK") diff --git a/tests/outcomes/plot/violinplot/matplotlib/main.py b/tests/outcomes/plot/violinplot/matplotlib/main.py index 071f64bd..4ea242b2 100644 --- a/tests/outcomes/plot/violinplot/matplotlib/main.py +++ b/tests/outcomes/plot/violinplot/matplotlib/main.py @@ -1,9 +1,6 @@ def plot(): try: import matplotlib.pyplot as plt - import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/violinplot/matplotlib/test.py b/tests/outcomes/plot/violinplot/matplotlib/test.py index a66c826d..054e4689 100644 --- a/tests/outcomes/plot/violinplot/matplotlib/test.py +++ b/tests/outcomes/plot/violinplot/matplotlib/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.violinplot.test_violin_drawing import test_violin_drawing +from tests.outcomes.plot.violinplot.test_violin_drawing import \ + test_violin_drawing class TestMatplotlibViolin(PlottingTest): diff --git a/tests/outcomes/plot/violinplot/seaborn/main.py b/tests/outcomes/plot/violinplot/seaborn/main.py index 95d922b7..89411c54 100644 --- a/tests/outcomes/plot/violinplot/seaborn/main.py +++ b/tests/outcomes/plot/violinplot/seaborn/main.py @@ -2,8 +2,6 @@ def plot(): try: import matplotlib.pyplot as plt import seaborn as sns - import pandas as pd - import numpy as np except ModuleNotFoundError: return diff --git a/tests/outcomes/plot/violinplot/seaborn/test.py b/tests/outcomes/plot/violinplot/seaborn/test.py index f9463762..6cdb8af2 100644 --- a/tests/outcomes/plot/violinplot/seaborn/test.py +++ b/tests/outcomes/plot/violinplot/seaborn/test.py @@ -2,7 +2,8 @@ from hstest.dynamic.dynamic_test import dynamic_test from hstest.stage import PlottingTest from hstest.testing.plotting.drawing.drawing_library import DrawingLibrary -from tests.outcomes.plot.violinplot.test_violin_drawing import test_violin_drawing +from tests.outcomes.plot.violinplot.test_violin_drawing import \ + test_violin_drawing class TestSeabornViolin(PlottingTest): diff --git a/tests/outcomes/plot/violinplot/test_violin_drawing.py b/tests/outcomes/plot/violinplot/test_violin_drawing.py index 6ad91342..3027c7ff 100644 --- a/tests/outcomes/plot/violinplot/test_violin_drawing.py +++ b/tests/outcomes/plot/violinplot/test_violin_drawing.py @@ -4,15 +4,17 @@ def test_violin_drawing(figures, correct_plot_count, library_type): if len(figures) != correct_plot_count: return wrong( - f'Expected {correct_plot_count} plots to be plotted ' - f'using {library_type} library, found {len(figures)}' + f"Expected {correct_plot_count} plots to be plotted " + f"using {library_type} library, found {len(figures)}" ) for i, violin in enumerate(figures): - if violin.type != 'violin': - return wrong(f'Wrong drawing type {violin.type}. Expected violin') + if violin.type != "violin": + return wrong(f"Wrong drawing type {violin.type}. Expected violin") if violin.library != library_type: - return wrong(f'{violin.library} is wrong library type. Expected {library_type}') + return wrong( + f"{violin.library} is wrong library type. Expected {library_type}" + ) return correct() diff --git a/tests/outcomes/repeating/test_repeating/test.py b/tests/outcomes/repeating/test_repeating/test.py index c5808470..19e1ae7f 100644 --- a/tests/outcomes/repeating/test_repeating/test.py +++ b/tests/outcomes/repeating/test_repeating/test.py @@ -12,4 +12,4 @@ def test(self): @dynamic_test def test2(self): - return wrong('') + return wrong("") diff --git a/tests/outcomes/repeating/test_repeating_2/test.py b/tests/outcomes/repeating/test_repeating_2/test.py index e38a6a5d..bc3ab3c0 100644 --- a/tests/outcomes/repeating/test_repeating_2/test.py +++ b/tests/outcomes/repeating/test_repeating_2/test.py @@ -12,7 +12,7 @@ def test(self): @dynamic_test() def test2(self): - return wrong('') + return wrong("") @dynamic_test(repeat=5) def test3(self): diff --git a/tests/outcomes/repeating/test_repeating_3/test.py b/tests/outcomes/repeating/test_repeating_3/test.py index 120af91c..997ed4a4 100644 --- a/tests/outcomes/repeating/test_repeating_3/test.py +++ b/tests/outcomes/repeating/test_repeating_3/test.py @@ -16,4 +16,4 @@ def test3(self): @dynamic_test() def test2(self): - return wrong('') + return wrong("") diff --git a/tests/outcomes/repeating/test_repeating_with_parametrized_tests/test.py b/tests/outcomes/repeating/test_repeating_with_parametrized_tests/test.py index 2f6a79ea..c9d392aa 100644 --- a/tests/outcomes/repeating/test_repeating_with_parametrized_tests/test.py +++ b/tests/outcomes/repeating/test_repeating_with_parametrized_tests/test.py @@ -6,9 +6,7 @@ class TestRepeatingWithParametrizedTests(UserErrorTest): contain = "Wrong answer in test #31" - data = [ - 1, 2, 3, 4, 5, 6 - ] + data = [1, 2, 3, 4, 5, 6] @dynamic_test(repeat=5, data=data) def test(self, x): @@ -16,4 +14,4 @@ def test(self, x): @dynamic_test() def test2(self): - return wrong('') + return wrong("") diff --git a/tests/outcomes/repeating/test_repeating_wrong_amount/test.py b/tests/outcomes/repeating/test_repeating_wrong_amount/test.py index 380c2b06..397a0c7f 100644 --- a/tests/outcomes/repeating/test_repeating_wrong_amount/test.py +++ b/tests/outcomes/repeating/test_repeating_wrong_amount/test.py @@ -4,7 +4,7 @@ class TestRepeatingWrongAmount(UnexpectedErrorTest): - contain = "UnexpectedError: Dynamic test \"test\" should not be repeated < 0 times, found -1" + contain = 'UnexpectedError: Dynamic test "test" should not be repeated < 0 times, found -1' @dynamic_test(repeat=-1) def test(self, x): diff --git a/tests/outcomes/runtime_exit/test_quit/test.py b/tests/outcomes/runtime_exit/test_quit/test.py index a67fe9d4..376d1d91 100644 --- a/tests/outcomes/runtime_exit/test_quit/test.py +++ b/tests/outcomes/runtime_exit/test_quit/test.py @@ -9,9 +9,7 @@ class TestQuit(UserErrorTest): contain = "Wrong answer in test #1" def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_check/test.py b/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_check/test.py index 94ba79c2..57f1b255 100644 --- a/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_check/test.py +++ b/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_check/test.py @@ -12,14 +12,12 @@ class UnexpectedErrorRuntimeExitInCheck(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, # noqa: W293 - 'ExitException' + "ExitException", ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: quit(0) - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_dynamic_input/test.py b/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_dynamic_input/test.py index 18dcd1f0..bf6eab40 100644 --- a/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_dynamic_input/test.py +++ b/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_dynamic_input/test.py @@ -12,23 +12,24 @@ class UnexpectedErrorRuntimeExitInDynamicInput(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, # noqa: W293 - "ExitException" + "ExitException", ] def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[lambda x: '123']), + TestCase(stdin=[lambda x: "123"]), TestCase(stdin=[self.add_input_1]), TestCase(stdin=[self.add_input_2]), ] def add_input_1(self, stdin: str): - return '123' + return "123" def add_input_2(self, stdin: str): import sys + sys.exit(0) - return '123' + return "123" def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_generate/test.py b/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_generate/test.py index d2f2119f..7ddb0b85 100644 --- a/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_generate/test.py +++ b/tests/outcomes/runtime_exit/unexpected_error_runtime_exit_in_generate/test.py @@ -12,15 +12,14 @@ class UnexpectedErrorRuntimeExitInGenerate(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "ExitException" + "ExitException", ] def generate(self) -> List[TestCase]: import os - os.__dict__['_exit'](0) - return [ - TestCase() - ] + + os.__dict__["_exit"](0) + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/search/go_files/go_files1/tests.py b/tests/outcomes/search/go_files/go_files1/tests.py index 70000b80..0d89472c 100644 --- a/tests/outcomes/search/go_files/go_files1/tests.py +++ b/tests/outcomes/search/go_files/go_files1/tests.py @@ -15,4 +15,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/search/go_files/go_files2/tests.py b/tests/outcomes/search/go_files/go_files2/tests.py index 1113c3d1..b707f8a6 100644 --- a/tests/outcomes/search/go_files/go_files2/tests.py +++ b/tests/outcomes/search/go_files/go_files2/tests.py @@ -17,9 +17,10 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/outcomes/search/go_files/go_files3/tests.py b/tests/outcomes/search/go_files/go_files3/tests.py index 0e499e38..71087d62 100644 --- a/tests/outcomes/search/go_files/go_files3/tests.py +++ b/tests/outcomes/search/go_files/go_files3/tests.py @@ -14,4 +14,4 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main.py index 1334a7cd..ccb147f9 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main.py @@ -1,2 +1,2 @@ -import main2 + print("Module no info") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main2.py index 90556e8a..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports/dir/main2.py @@ -1,2 +1,2 @@ -import main3, main4 + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports/test.py index 1de3ded7..ac9f7a2f 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports/test.py @@ -10,8 +10,5 @@ def test(self): main = TestedProgram() result = main.start() return CheckResult( - result == - 'Main 3\n' - 'Main 4\n' - 'Main 2\n' - 'Module no info\n', '') + result == "Main 3\n" "Main 4\n" "Main 2\n" "Module no info\n", "" + ) diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main.py index a5bc3e01..94c608e1 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main.py @@ -1,2 +1,3 @@ from main2 import x + print(x) diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main2.py index 9421e10d..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/dir/main2.py @@ -1,3 +1,2 @@ -import main3 -from main4 import x + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/test.py index 1de3ded7..ac9f7a2f 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_2/test.py @@ -10,8 +10,5 @@ def test(self): main = TestedProgram() result = main.start() return CheckResult( - result == - 'Main 3\n' - 'Main 4\n' - 'Main 2\n' - 'Module no info\n', '') + result == "Main 3\n" "Main 4\n" "Main 2\n" "Module no info\n", "" + ) diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main.py index a5bc3e01..94c608e1 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main.py @@ -1,2 +1,3 @@ from main2 import x + print(x) diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main2.py index b53a754f..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/dir/main2.py @@ -1,2 +1,2 @@ -import main3 + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/test.py index 942e5268..8c4235fb 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_imports_3/test.py @@ -17,8 +17,5 @@ def test(self): main = TestedProgram() result = main.start() return CheckResult( - result == - 'Main 3\n' - 'Main 4\n' - 'Main 2\n' - 'Module no info\n', '') + result == "Main 3\n" "Main 4\n" "Main 2\n" "Module no info\n", "" + ) diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main.py index 87d7be8f..b9264ec3 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main.py @@ -1,4 +1,3 @@ -import main2 -if __name__ == '__main__': +if __name__ == "__main__": pass diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main2.py index b53a754f..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/dir/main2.py @@ -1,2 +1,2 @@ -import main3 + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/test.py index 55087c0b..0adac120 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main/test.py @@ -9,7 +9,4 @@ class FindModuleNoInfoAnalyzeImports(StageTest): def test(self): main = TestedProgram() result = main.start() - return CheckResult( - result == - 'Main 3\n' - 'Main 2\n', '') + return CheckResult(result == "Main 3\n" "Main 2\n", "") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main.py index 0c41b81a..b9264ec3 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main.py @@ -1,4 +1,3 @@ -import main2 if __name__ == "__main__": pass diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main2.py index b53a754f..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/dir/main2.py @@ -1,2 +1,2 @@ -import main3 + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/test.py index 55087c0b..0adac120 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_2/test.py @@ -9,7 +9,4 @@ class FindModuleNoInfoAnalyzeImports(StageTest): def test(self): main = TestedProgram() result = main.start() - return CheckResult( - result == - 'Main 3\n' - 'Main 2\n', '') + return CheckResult(result == "Main 3\n" "Main 2\n", "") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main.py index 0c41b81a..b9264ec3 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main.py @@ -1,4 +1,3 @@ -import main2 if __name__ == "__main__": pass diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main2.py index b53a754f..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/dir/main2.py @@ -1,2 +1,2 @@ -import main3 + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/test.py index 721828c8..a1f9d4b6 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_3/test.py @@ -16,7 +16,4 @@ class FindModuleNoInfoAnalyzeImports(UserErrorTest): def test(self): main = TestedProgram() result = main.start() - return CheckResult( - result == - 'Main 3\n' - 'Main 2\n', '') + return CheckResult(result == "Main 3\n" "Main 2\n", "") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main.py index 0c41b81a..b9264ec3 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main.py @@ -1,4 +1,3 @@ -import main2 if __name__ == "__main__": pass diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main2.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main2.py index b53a754f..f6dea21e 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main2.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main2.py @@ -1,2 +1,2 @@ -import main3 + print("Main 2") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main3.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main3.py index 44273f6b..bad759d7 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main3.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/dir/main3.py @@ -1,2 +1,2 @@ -import main4 + print("Main 3") diff --git a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/test.py b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/test.py index 37567f19..8ff9f42c 100644 --- a/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/test.py +++ b/tests/outcomes/separate_package/find_module_no_info_analyze_name_main_4/test.py @@ -9,8 +9,4 @@ class FindModuleNoInfoAnalyzeImports(StageTest): def test(self): main = TestedProgram() result = main.start() - return CheckResult( - result == - 'Main 4\n' - 'Main 3\n' - 'Main 2\n', '') + return CheckResult(result == "Main 4\n" "Main 3\n" "Main 2\n", "") diff --git a/tests/outcomes/simple_test/test_simple_test_case/test.py b/tests/outcomes/simple_test/test_simple_test_case/test.py index 3dcc351f..2ecc8946 100644 --- a/tests/outcomes/simple_test/test_simple_test_case/test.py +++ b/tests/outcomes/simple_test/test_simple_test_case/test.py @@ -8,6 +8,6 @@ class TesSimpleTestCase(StageTest): def generate(self) -> List[TestCase]: return [ - SimpleTestCase(stdin="123", stdout="123\n123", feedback=''), - SimpleTestCase(stdin="567", stdout="567\n567", feedback='') + SimpleTestCase(stdin="123", stdout="123\n123", feedback=""), + SimpleTestCase(stdin="567", stdout="567\n567", feedback=""), ] diff --git a/tests/outcomes/simple_test/test_simple_test_case_fail/test.py b/tests/outcomes/simple_test/test_simple_test_case_fail/test.py index 3178a6dd..47b963d3 100644 --- a/tests/outcomes/simple_test/test_simple_test_case_fail/test.py +++ b/tests/outcomes/simple_test/test_simple_test_case_fail/test.py @@ -21,10 +21,14 @@ class TesSimpleTestCaseFail(UserErrorTest): def generate(self) -> List[TestCase]: return [ - SimpleTestCase(stdin="123", - stdout="123\n123", - feedback="You should output a number twice"), - SimpleTestCase(stdin="567", - stdout="567\n567", - feedback="You should output this number twice") + SimpleTestCase( + stdin="123", + stdout="123\n123", + feedback="You should output a number twice", + ), + SimpleTestCase( + stdin="567", + stdout="567\n567", + feedback="You should output this number twice", + ), ] diff --git a/tests/outcomes/stderr/disable_catching_stderr/main.py b/tests/outcomes/stderr/disable_catching_stderr/main.py index 2d7d872c..42003eee 100644 --- a/tests/outcomes/stderr/disable_catching_stderr/main.py +++ b/tests/outcomes/stderr/disable_catching_stderr/main.py @@ -1,3 +1,3 @@ import sys -print('text from stderr', file=sys.stderr) +print("text from stderr", file=sys.stderr) diff --git a/tests/outcomes/stderr/disable_catching_stderr/test.py b/tests/outcomes/stderr/disable_catching_stderr/test.py index d2c4a2fa..869034a3 100644 --- a/tests/outcomes/stderr/disable_catching_stderr/test.py +++ b/tests/outcomes/stderr/disable_catching_stderr/test.py @@ -1,13 +1,10 @@ -from hstest.testing.unittest.user_error_test import UserErrorTest +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.settings import Settings -from hstest import dynamic_test, TestedProgram, wrong +from hstest.testing.unittest.user_error_test import UserErrorTest class TestDisableStderrCatch(UserErrorTest): - not_contain = [ - 'stderr:', - 'text from stderr' - ] + not_contain = ["stderr:", "text from stderr"] @dynamic_test def test(self): @@ -15,4 +12,4 @@ def test(self): program = TestedProgram() program.start() Settings.catch_stderr = True - return wrong('Something is wrong!') + return wrong("Something is wrong!") diff --git a/tests/outcomes/stderr/dynamically_change_stderr_catching/main.py b/tests/outcomes/stderr/dynamically_change_stderr_catching/main.py index 2d7d872c..42003eee 100644 --- a/tests/outcomes/stderr/dynamically_change_stderr_catching/main.py +++ b/tests/outcomes/stderr/dynamically_change_stderr_catching/main.py @@ -1,3 +1,3 @@ import sys -print('text from stderr', file=sys.stderr) +print("text from stderr", file=sys.stderr) diff --git a/tests/outcomes/stderr/dynamically_change_stderr_catching/test.py b/tests/outcomes/stderr/dynamically_change_stderr_catching/test.py index 993e1b30..e3aa3d5e 100644 --- a/tests/outcomes/stderr/dynamically_change_stderr_catching/test.py +++ b/tests/outcomes/stderr/dynamically_change_stderr_catching/test.py @@ -1,13 +1,10 @@ -from hstest.testing.unittest.user_error_test import UserErrorTest +from hstest import TestedProgram, dynamic_test, wrong from hstest.testing.settings import Settings -from hstest import dynamic_test, TestedProgram, wrong +from hstest.testing.unittest.user_error_test import UserErrorTest class TestDynamicStderrCatch(UserErrorTest): - contain = [ - 'stderr:', - 'text from stderr' - ] + contain = ["stderr:", "text from stderr"] @dynamic_test def test(self): @@ -23,4 +20,4 @@ def test(self): program = TestedProgram() program.start() Settings.catch_stderr = True - return wrong('Something is wrong!') + return wrong("Something is wrong!") diff --git a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stderr_and_with_stdout/test.py b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stderr_and_with_stdout/test.py index 44b58f4c..74887979 100644 --- a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stderr_and_with_stdout/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stderr_and_with_stdout/test.py @@ -26,9 +26,7 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): User stderr output!""" # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase(args=['test', 'args']) - ] + return [TestCase(args=["test", "args"])] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stdout_and_without_stderr/test.py b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stdout_and_without_stderr/test.py index 539202d0..072a9808 100644 --- a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stdout_and_without_stderr/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_with_stdout_and_without_stderr/test.py @@ -21,9 +21,7 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): """ # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase(args=['test', 'args']) - ] + return [TestCase(args=["test", "args"])] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stderr_and_without_stdout/test.py b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stderr_and_without_stdout/test.py index 6dfa9a9c..8f7d3d7a 100644 --- a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stderr_and_without_stdout/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stderr_and_without_stdout/test.py @@ -7,15 +7,10 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): contain = "Arguments: test args" - not_contain = [ - "stderr:", - "stdout:" - ] + not_contain = ["stderr:", "stdout:"] def generate(self) -> List[TestCase]: - return [ - TestCase(args=['test', 'args']) - ] + return [TestCase(args=["test", "args"])] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stdout_and_with_stderr/test.py b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stdout_and_with_stderr/test.py index 83d467ab..b00058c7 100644 --- a/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stdout_and_with_stderr/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/with_args/test_output_without_stdout_and_with_stderr/test.py @@ -21,9 +21,7 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): User stderr output!""" # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase(args=['test', 'args']) - ] + return [TestCase(args=["test", "args"])] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stderr_and_with_stdout/test.py b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stderr_and_with_stdout/test.py index 9887cba1..599ef324 100644 --- a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stderr_and_with_stdout/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stderr_and_with_stdout/test.py @@ -25,9 +25,7 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): """ # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stdout_and_without_stderr/test.py b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stdout_and_without_stderr/test.py index 862347d6..f611a275 100644 --- a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stdout_and_without_stderr/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_with_stdout_and_without_stderr/test.py @@ -19,9 +19,7 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): """ # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stderr_and_without_stdout/test.py b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stderr_and_without_stdout/test.py index 04a5d23c..a025428a 100644 --- a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stderr_and_without_stdout/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stderr_and_without_stdout/test.py @@ -6,15 +6,10 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): - not_contain = [ - 'stderr:', - 'stdout:' - ] + not_contain = ["stderr:", "stdout:"] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stdout_and_with_stderr/test.py b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stdout_and_with_stderr/test.py index 8364119a..dddac0d5 100644 --- a/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stdout_and_with_stderr/test.py +++ b/tests/outcomes/stderr_on_unexpected_error/without_args/test_output_without_stdout_and_with_stderr/test.py @@ -20,9 +20,7 @@ class TestOutputWithStderrAndWithStdout(UserErrorTest): """ # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/syntax_error/test_empty_eval/test.py b/tests/outcomes/syntax_error/test_empty_eval/test.py index e24dce10..9158bbc8 100644 --- a/tests/outcomes/syntax_error/test_empty_eval/test.py +++ b/tests/outcomes/syntax_error/test_empty_eval/test.py @@ -13,10 +13,8 @@ class TestEmptyEval(UserErrorTest): File "main.py", line 1, in print(eval("")) File "", line 0""", - "SyntaxError: " + "SyntaxError: ", ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/syntax_error/test_error_using_eval/test.py b/tests/outcomes/syntax_error/test_error_using_eval/test.py index 95cab756..c9d34144 100644 --- a/tests/outcomes/syntax_error/test_error_using_eval/test.py +++ b/tests/outcomes/syntax_error/test_error_using_eval/test.py @@ -14,10 +14,8 @@ class TestEmptyEval(UserErrorTest): print(eval(")")) File "", line 1 """, - "SyntaxError: " + "SyntaxError: ", ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/syntax_error/test_error_using_eval_and_print/test.py b/tests/outcomes/syntax_error/test_error_using_eval_and_print/test.py index a34e5fe1..f2e0ce66 100644 --- a/tests/outcomes/syntax_error/test_error_using_eval_and_print/test.py +++ b/tests/outcomes/syntax_error/test_error_using_eval_and_print/test.py @@ -21,10 +21,8 @@ class TestEmptyEval(UserErrorTest): --- 123 - """ # noqa: W293 + """, # noqa: W293 ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/syntax_error/test_error_using_exec/test.py b/tests/outcomes/syntax_error/test_error_using_exec/test.py index 2a868d4a..cd49d281 100644 --- a/tests/outcomes/syntax_error/test_error_using_exec/test.py +++ b/tests/outcomes/syntax_error/test_error_using_exec/test.py @@ -14,10 +14,8 @@ class TestSyntaxError1(UserErrorTest): exec("print)") File "", line 1 """, - "SyntaxError: " + "SyntaxError: ", ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/syntax_error/test_syntax_error_1/test.py b/tests/outcomes/syntax_error/test_syntax_error_1/test.py index 830fa2ec..12c2cc43 100644 --- a/tests/outcomes/syntax_error/test_syntax_error_1/test.py +++ b/tests/outcomes/syntax_error/test_syntax_error_1/test.py @@ -16,6 +16,4 @@ class TestSyntaxError1(UserErrorTest): """ # noqa: W291 def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/syntax_error/test_syntax_error_2/test.py b/tests/outcomes/syntax_error/test_syntax_error_2/test.py index d4eebb24..2dea5cc1 100644 --- a/tests/outcomes/syntax_error/test_syntax_error_2/test.py +++ b/tests/outcomes/syntax_error/test_syntax_error_2/test.py @@ -15,10 +15,8 @@ class TestSyntaxError2(UserErrorTest): """, """ SyntaxError: - """ # noqa: W291 + """, # noqa: W291 ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_1/test.py b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_1/test.py index 398213b9..b124956c 100644 --- a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_1/test.py +++ b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_1/test.py @@ -13,10 +13,7 @@ class TestPassedThrownInCheck1(UserErrorTest): test is not passed attach true""" def generate(self) -> List[TestCase]: - return [ - TestCase(attach=True), - TestCase(attach=False) - ] + return [TestCase(attach=True), TestCase(attach=False)] def check(self, reply: str, attach: Any) -> CheckResult: if not attach: diff --git a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_2/test.py b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_2/test.py index 18dd0716..c261d393 100644 --- a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_2/test.py +++ b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_check_2/test.py @@ -14,10 +14,7 @@ class TestPassedThrownInCheck2(UserErrorTest): """ # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase(attach=True), - TestCase(attach=False) - ] + return [TestCase(attach=True), TestCase(attach=False)] def check(self, reply: str, attach: Any) -> CheckResult: if attach: diff --git a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/main.py b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/main.py index 1251f9ac..9bead51d 100644 --- a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/main.py +++ b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/main.py @@ -1,2 +1,2 @@ -print("1", end='') +print("1", end="") input() diff --git a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/test.py b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/test.py index c0297cb7..95492ce1 100644 --- a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/test.py +++ b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_1/test.py @@ -14,20 +14,17 @@ class TestPassedThrownInDynamicInput1(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[self.dynamic1]), - TestCase(stdin=[self.dynamic2]) - ] + return [TestCase(stdin=[self.dynamic1]), TestCase(stdin=[self.dynamic2])] def dynamic1(self, out): - if out == '1': + if out == "1": raise TestPassed() - return '2' + return "2" def dynamic2(self, out): - if out == '2': + if out == "2": raise TestPassed() - return '1' + return "1" def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.wrong("fail inside check") diff --git a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/main.py b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/main.py index 48effbc9..2bf7e2fe 100644 --- a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/main.py +++ b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/main.py @@ -1,2 +1,2 @@ -print("2", end='') +print("2", end="") input() diff --git a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/test.py b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/test.py index aeaf7938..71ca1b12 100644 --- a/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/test.py +++ b/tests/outcomes/test_passed_thrown/test_passed_thrown_in_dynamic_input_2/test.py @@ -14,20 +14,17 @@ class TestPassedThrownInDynamicInput2(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[self.dynamic1]), - TestCase(stdin=[self.dynamic2]) - ] + return [TestCase(stdin=[self.dynamic1]), TestCase(stdin=[self.dynamic2])] def dynamic1(self, out): - if out == '1': + if out == "1": raise TestPassed() - return '2' + return "2" def dynamic2(self, out): - if out == '2': + if out == "2": raise TestPassed() - return '1' + return "1" def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.wrong("fail inside check") diff --git a/tests/outcomes/timeout/test_default_time_limit/main.py b/tests/outcomes/timeout/test_default_time_limit/main.py index a71866e0..2d9e1325 100644 --- a/tests/outcomes/timeout/test_default_time_limit/main.py +++ b/tests/outcomes/timeout/test_default_time_limit/main.py @@ -1,2 +1,3 @@ from time import sleep + sleep(16) diff --git a/tests/outcomes/timeout/test_default_time_limit/test.py b/tests/outcomes/timeout/test_default_time_limit/test.py index 6beed805..595eec57 100644 --- a/tests/outcomes/timeout/test_default_time_limit/test.py +++ b/tests/outcomes/timeout/test_default_time_limit/test.py @@ -6,18 +6,16 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('takes too loong') +@unittest.skip("takes too loong") class TestDefaultTimeLimit(UserErrorTest): contain = [ "Error in test #1", "In this test, the program is running for a long time, more than 15 seconds. " - "Most likely, the program has gone into an infinite loop." + "Most likely, the program has gone into an infinite loop.", ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/timeout/test_no_time_limit/main.py b/tests/outcomes/timeout/test_no_time_limit/main.py index a71866e0..2d9e1325 100644 --- a/tests/outcomes/timeout/test_no_time_limit/main.py +++ b/tests/outcomes/timeout/test_no_time_limit/main.py @@ -1,2 +1,3 @@ from time import sleep + sleep(16) diff --git a/tests/outcomes/timeout/test_no_time_limit/test.py b/tests/outcomes/timeout/test_no_time_limit/test.py index 45d02138..c1238c73 100644 --- a/tests/outcomes/timeout/test_no_time_limit/test.py +++ b/tests/outcomes/timeout/test_no_time_limit/test.py @@ -6,7 +6,7 @@ from hstest.test_case import TestCase -@unittest.skip('takes too long') +@unittest.skip("takes too long") class TestNoTimeLimit(StageTest): def generate(self) -> List[TestCase]: diff --git a/tests/outcomes/timeout/test_timeout_1/main.py b/tests/outcomes/timeout/test_timeout_1/main.py index c02a7bcd..33aa0182 100644 --- a/tests/outcomes/timeout/test_timeout_1/main.py +++ b/tests/outcomes/timeout/test_timeout_1/main.py @@ -1,2 +1,3 @@ from time import sleep + sleep(int(input()) / 1000) diff --git a/tests/outcomes/timeout/test_timeout_1/test.py b/tests/outcomes/timeout/test_timeout_1/test.py index e2b8bc5d..0d3755ac 100644 --- a/tests/outcomes/timeout/test_timeout_1/test.py +++ b/tests/outcomes/timeout/test_timeout_1/test.py @@ -6,18 +6,18 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('takes too long') +@unittest.skip("takes too long") class TestTimeout1(UserErrorTest): contain = [ "Error in test #2", "In this test, the program is running for a long time, more than 500 milliseconds. " - "Most likely, the program has gone into an infinite loop." + "Most likely, the program has gone into an infinite loop.", ] def generate(self) -> List[TestCase]: return [ TestCase(stdin="400", time_limit=500), - TestCase(stdin="600", time_limit=500) + TestCase(stdin="600", time_limit=500), ] def check(self, reply: str, attach: Any) -> CheckResult: diff --git a/tests/outcomes/timeout/test_timeout_2/main.py b/tests/outcomes/timeout/test_timeout_2/main.py index c02a7bcd..33aa0182 100644 --- a/tests/outcomes/timeout/test_timeout_2/main.py +++ b/tests/outcomes/timeout/test_timeout_2/main.py @@ -1,2 +1,3 @@ from time import sleep + sleep(int(input()) / 1000) diff --git a/tests/outcomes/timeout/test_timeout_2/test.py b/tests/outcomes/timeout/test_timeout_2/test.py index b709578b..128d3664 100644 --- a/tests/outcomes/timeout/test_timeout_2/test.py +++ b/tests/outcomes/timeout/test_timeout_2/test.py @@ -6,12 +6,12 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('takes too long') +@unittest.skip("takes too long") class TestTimeout2(UserErrorTest): contain = [ - 'Error in test #3', - 'In this test, the program is running for a long time, more than 300 milliseconds. ' - 'Most likely, the program has gone into an infinite loop.' + "Error in test #3", + "In this test, the program is running for a long time, more than 300 milliseconds. " + "Most likely, the program has gone into an infinite loop.", ] def generate(self) -> List[TestCase]: diff --git a/tests/outcomes/timeout/test_timeout_3/test.py b/tests/outcomes/timeout/test_timeout_3/test.py index a92d12c5..3220d989 100644 --- a/tests/outcomes/timeout/test_timeout_3/test.py +++ b/tests/outcomes/timeout/test_timeout_3/test.py @@ -6,12 +6,12 @@ from hstest.testing.unittest.user_error_test import UserErrorTest -@unittest.skip('take too long') +@unittest.skip("take too long") class TestTimeout3(UserErrorTest): contain = [ - 'Error in test #1', - 'In this test, the program is running for a long time, more than 2 seconds. ' - 'Most likely, the program has gone into an infinite loop.' + "Error in test #1", + "In this test, the program is running for a long time, more than 2 seconds. " + "Most likely, the program has gone into an infinite loop.", ] def generate(self) -> List[TestCase]: diff --git a/tests/outcomes/unexpected_error/unexpected_error_add_input_1/test.py b/tests/outcomes/unexpected_error/unexpected_error_add_input_1/test.py index ab8b84c2..480b8bcc 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_add_input_1/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_add_input_1/test.py @@ -12,13 +12,11 @@ class UnexpectedErrorAddInput1(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "ZeroDivisionError: division by zero" + "ZeroDivisionError: division by zero", ] def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[lambda x: f'{0 / 0}']) - ] + return [TestCase(stdin=[lambda x: f"{0 / 0}"])] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_add_input_2/test.py b/tests/outcomes/unexpected_error/unexpected_error_add_input_2/test.py index 3cb5467f..02efdec3 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_add_input_2/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_add_input_2/test.py @@ -12,13 +12,11 @@ class UnexpectedErrorAddInput2(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "ZeroDivisionError: division by zero" + "ZeroDivisionError: division by zero", ] def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[(2, lambda x: f'{0 / 0}')]) - ] + return [TestCase(stdin=[(2, lambda x: f"{0 / 0}")])] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_add_input_3/test.py b/tests/outcomes/unexpected_error/unexpected_error_add_input_3/test.py index 6bf4c098..e493024a 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_add_input_3/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_add_input_3/test.py @@ -12,16 +12,16 @@ class UnexpectedErrorAddInput3(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "Dynamic input should return str or CheckResult objects only. Found: " + "Dynamic input should return str or CheckResult objects only. Found: ", ] def generate(self) -> List[TestCase]: return [ - TestCase(stdin=['12'], attach='1\n12\n'), + TestCase(stdin=["12"], attach="1\n12\n"), TestCase(stdin=[lambda x: CheckResult.correct()]), - TestCase(stdin=[lambda x: CheckResult(x == '1\n', x + '56')]), - TestCase(stdin=[lambda x: 78]) + TestCase(stdin=[lambda x: CheckResult(x == "1\n", x + "56")]), + TestCase(stdin=[lambda x: 78]), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_during_checking/main.py b/tests/outcomes/unexpected_error/unexpected_error_during_checking/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_during_checking/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_during_checking/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_during_checking/test.py b/tests/outcomes/unexpected_error/unexpected_error_during_checking/test.py index eb735adb..1167bff4 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_during_checking/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_during_checking/test.py @@ -17,4 +17,4 @@ def generate(self) -> List[TestCase]: def check(self, reply: str, attach: Any) -> CheckResult: x = 0 / 0 # noqa: F841 - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/main.py b/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/test.py b/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/test.py index 46fd27a3..b95df5c4 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_during_checking_with_assertion/test.py @@ -16,6 +16,6 @@ def generate(self) -> List[TestCase]: return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - if reply == 'Hello World\n': + if reply == "Hello World\n": assert False - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/main.py b/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/test.py b/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/test.py index b00a9379..60c86d91 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_empty_test_cases/test.py @@ -12,11 +12,11 @@ class UnexpectedErrorEmptyTestCases(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "No tests found" + "No tests found", ] def generate(self) -> List[TestCase]: return [] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_generating_tests/main.py b/tests/outcomes/unexpected_error/unexpected_error_generating_tests/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_generating_tests/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_generating_tests/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_generating_tests/test.py b/tests/outcomes/unexpected_error/unexpected_error_generating_tests/test.py index 942db564..b4a1424b 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_generating_tests/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_generating_tests/test.py @@ -16,9 +16,7 @@ class UnexpectedErrorGeneratingTests(UnexpectedErrorTest): def generate(self) -> List[TestCase]: x = 0 / 0 # noqa: F841 - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/main.py b/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/test.py b/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/test.py index e662cdfb..e0eba09a 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_generating_tests_with_assertion/test.py @@ -17,4 +17,4 @@ def generate(self): assert False def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/unexpected_error/unexpected_error_no_check_method/main.py b/tests/outcomes/unexpected_error/unexpected_error_no_check_method/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_no_check_method/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_no_check_method/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_no_check_method/test.py b/tests/outcomes/unexpected_error/unexpected_error_no_check_method/test.py index c18e4a9c..14067939 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_no_check_method/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_no_check_method/test.py @@ -11,10 +11,8 @@ class UnexpectedErrorNotGeneratingTests(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "Can't check result: override \"check\" method" + 'Can\'t check result: override "check" method', ] def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] diff --git a/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/main.py b/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/main.py index df1dc682..ad35e5ae 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/main.py +++ b/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/main.py @@ -1 +1 @@ -print('Hello World') +print("Hello World") diff --git a/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/test.py b/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/test.py index 6d95524e..f2796906 100644 --- a/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/test.py +++ b/tests/outcomes/unexpected_error/unexpected_error_not_generating_tests/test.py @@ -11,8 +11,8 @@ class UnexpectedErrorNotGeneratingTests(UnexpectedErrorTest): We have recorded this bug and will fix it soon. """, - "No tests found" + "No tests found", ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(True, '') + return CheckResult(True, "") diff --git a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/main.py b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/main.py index 1e1ab54a..b5516f90 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/main.py +++ b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/main.py @@ -1,2 +1,2 @@ -print('1') +print("1") input() diff --git a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/test.py b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/test.py index f996e335..8d65526a 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/test.py +++ b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_1/test.py @@ -18,4 +18,4 @@ def generate(self) -> List[TestCase]: ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/main.py b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/main.py index b5583873..27b49821 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/main.py +++ b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/main.py @@ -1,2 +1,2 @@ -print('1') +print("1") print(input()) diff --git a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/test.py b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/test.py index 2cba2ac4..5f43fd71 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/test.py +++ b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_2/test.py @@ -14,14 +14,15 @@ class WrongAnswerDynamicInput2(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[ - lambda x: "2" if x == "1\n" else CheckResult.wrong("WA TEST 1") - ], attach="1\n2\n"), - - TestCase(stdin=[ - lambda x: "3" if x == "2" else CheckResult.wrong("WA TEST 2") - ], attach="2\n3\n"), + TestCase( + stdin=[lambda x: "2" if x == "1\n" else CheckResult.wrong("WA TEST 1")], + attach="1\n2\n", + ), + TestCase( + stdin=[lambda x: "3" if x == "2" else CheckResult.wrong("WA TEST 2")], + attach="2\n3\n", + ), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_3/test.py b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_3/test.py index 52db05c5..c7fa4567 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_3/test.py +++ b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_3/test.py @@ -14,22 +14,36 @@ class WrongAnswerDynamicInput3(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[ - (-1, lambda x: CheckResult.correct()) - ], attach="1\n2\n2\n"), - - TestCase(stdin=[ - lambda x: CheckResult.correct() if x == "" else CheckResult.wrong("WA TEST 2"), - (2, lambda x: ( - CheckResult.correct() if x == "3\n" else CheckResult.wrong("WA TEST 2")) - ) - ], attach="3\n3\n3\n"), - - TestCase(stdin=[ - lambda x: "3" if x == "" else CheckResult.wrong("WA TEST 3"), - (-1, lambda x: "4" if x == "3\n" else CheckResult.wrong("WA TEST 3")) - ], attach="3\n3\n4\n"), + TestCase(stdin=[(-1, lambda x: CheckResult.correct())], attach="1\n2\n2\n"), + TestCase( + stdin=[ + lambda x: ( + CheckResult.correct() + if x == "" + else CheckResult.wrong("WA TEST 2") + ), + ( + 2, + lambda x: ( + CheckResult.correct() + if x == "3\n" + else CheckResult.wrong("WA TEST 2") + ), + ), + ], + attach="3\n3\n3\n", + ), + TestCase( + stdin=[ + lambda x: "3" if x == "" else CheckResult.wrong("WA TEST 3"), + ( + -1, + lambda x: "4" if x == "3\n" else CheckResult.wrong("WA TEST 3"), + ), + ], + attach="3\n3\n4\n", + ), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_4/test.py b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_4/test.py index 168ce49b..957b28be 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_4/test.py +++ b/tests/outcomes/wrong_answer/wrong_answer_dynamic_input_4/test.py @@ -14,27 +14,29 @@ class WrongAnswerDynamicInput4(UserErrorTest): def generate(self) -> List[TestCase]: return [ - TestCase(stdin=[ - "1", - (2, lambda x: CheckResult.correct()) - ], attach="1\n2\n2\n"), - - TestCase(stdin=[ - (2, lambda x: "3"), - lambda x: "3", - lambda x: CheckResult.wrong("WA TEST 2") - ], attach="3\n3\n3\n"), - - TestCase(stdin=[ - (-1, lambda x: "4"), - lambda x: CheckResult.wrong("WA TEST 3") - ], attach="4\n4\n4\n"), - - TestCase(stdin=[ - (2, lambda x: "5"), - lambda x: CheckResult.wrong("WA TEST 4") if x == "5\n" else 5 - ], attach="4\n4\n4\n"), + TestCase( + stdin=["1", (2, lambda x: CheckResult.correct())], attach="1\n2\n2\n" + ), + TestCase( + stdin=[ + (2, lambda x: "3"), + lambda x: "3", + lambda x: CheckResult.wrong("WA TEST 2"), + ], + attach="3\n3\n3\n", + ), + TestCase( + stdin=[(-1, lambda x: "4"), lambda x: CheckResult.wrong("WA TEST 3")], + attach="4\n4\n4\n", + ), + TestCase( + stdin=[ + (2, lambda x: "5"), + lambda x: CheckResult.wrong("WA TEST 4") if x == "5\n" else 5, + ], + attach="4\n4\n4\n", + ), ] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(reply == attach, '') + return CheckResult(reply == attach, "") diff --git a/tests/outcomes/wrong_answer/wrong_answer_in_test_1/test.py b/tests/outcomes/wrong_answer/wrong_answer_in_test_1/test.py index 62a2e1da..75b9577b 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_in_test_1/test.py +++ b/tests/outcomes/wrong_answer/wrong_answer_in_test_1/test.py @@ -9,9 +9,7 @@ class WrongAnswerInTest1(UserErrorTest): contain = "Wrong answer in test #1" def generate(self) -> List[TestCase]: - return [ - TestCase() - ] + return [TestCase()] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(False, '') + return CheckResult(False, "") diff --git a/tests/outcomes/wrong_answer/wrong_answer_in_test_2/test.py b/tests/outcomes/wrong_answer/wrong_answer_in_test_2/test.py index b08fbdc3..7d6d2720 100644 --- a/tests/outcomes/wrong_answer/wrong_answer_in_test_2/test.py +++ b/tests/outcomes/wrong_answer/wrong_answer_in_test_2/test.py @@ -9,10 +9,7 @@ class WrongAnswerInTest2(UserErrorTest): contain = "Wrong answer in test #2" def generate(self) -> List[TestCase]: - return [ - TestCase(attach=True), - TestCase(attach=False) - ] + return [TestCase(attach=True), TestCase(attach=False)] def check(self, reply: str, attach: Any) -> CheckResult: - return CheckResult(attach, '') + return CheckResult(attach, "") diff --git a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_1/test.py b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_1/test.py index a1b16e66..7f91626d 100644 --- a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_1/test.py +++ b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_1/test.py @@ -14,12 +14,9 @@ class WrongAnswerThrownInCheck1(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(attach=True), - TestCase(attach=False) - ] + return [TestCase(attach=True), TestCase(attach=False)] def check(self, reply: str, attach: Any) -> CheckResult: if not attach: raise WrongAnswer("Wrong answer from check attach false") - return CheckResult(attach, '') + return CheckResult(attach, "") diff --git a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_2/test.py b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_2/test.py index 03ae7e99..134abee3 100644 --- a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_2/test.py +++ b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_check_2/test.py @@ -14,12 +14,9 @@ class WrongAnswerThrownInCheck2(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(attach=True), - TestCase(attach=False) - ] + return [TestCase(attach=True), TestCase(attach=False)] def check(self, reply: str, attach: Any) -> CheckResult: if attach: raise WrongAnswer("Wrong answer from check attach true") - return CheckResult(attach, '') + return CheckResult(attach, "") diff --git a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/main.py b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/main.py index 1251f9ac..9bead51d 100644 --- a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/main.py +++ b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/main.py @@ -1,2 +1,2 @@ -print("1", end='') +print("1", end="") input() diff --git a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/test.py b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/test.py index cabaae68..11ceac80 100644 --- a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/test.py +++ b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_1/test.py @@ -14,20 +14,17 @@ class WrongAnswerThrownInDynamicInput1(UserErrorTest): """ def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[self.dynamic1]), - TestCase(stdin=[self.dynamic2]) - ] + return [TestCase(stdin=[self.dynamic1]), TestCase(stdin=[self.dynamic2])] def dynamic1(self, out): - if out == '1': + if out == "1": raise WrongAnswer("Add input test 1") - return '2' + return "2" def dynamic2(self, out): - if out == '2': + if out == "2": raise WrongAnswer("Add input test 2") - return '1' + return "1" def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/main.py b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/main.py index 48effbc9..2bf7e2fe 100644 --- a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/main.py +++ b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/main.py @@ -1,2 +1,2 @@ -print("2", end='') +print("2", end="") input() diff --git a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/test.py b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/test.py index 48089675..a448c0a0 100644 --- a/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/test.py +++ b/tests/outcomes/wrong_answer_thrown/wrong_answer_thrown_in_dynamic_input_2/test.py @@ -14,20 +14,17 @@ class WrongAnswerThrownInDynamicInput2(UserErrorTest): """ # noqa: W293 def generate(self) -> List[TestCase]: - return [ - TestCase(stdin=[self.dynamic1]), - TestCase(stdin=[self.dynamic2]) - ] + return [TestCase(stdin=[self.dynamic1]), TestCase(stdin=[self.dynamic2])] def dynamic1(self, out): - if out == '1': + if out == "1": raise WrongAnswer("Add input test 1") - return '2' + return "2" def dynamic2(self, out): - if out == '2': + if out == "2": raise WrongAnswer("Add input test 2") - return '1' + return "1" def check(self, reply: str, attach: Any) -> CheckResult: return CheckResult.correct() diff --git a/tests/projects/go/coffee_machine/stage1/tests.py b/tests/projects/go/coffee_machine/stage1/tests.py index 98a5d79b..b707f8a6 100644 --- a/tests/projects/go/coffee_machine/stage1/tests.py +++ b/tests/projects/go/coffee_machine/stage1/tests.py @@ -3,7 +3,6 @@ from hstest.check_result import CheckResult from hstest.stage_test import StageTest from hstest.test_case import TestCase -from typing import List OUTPUT = """ Starting to make a coffee @@ -18,9 +17,10 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/go/coffee_machine/stage1_ce/tests.py b/tests/projects/go/coffee_machine/stage1_ce/tests.py index 37cf49e8..f20a2606 100644 --- a/tests/projects/go/coffee_machine/stage1_ce/tests.py +++ b/tests/projects/go/coffee_machine/stage1_ce/tests.py @@ -1,11 +1,12 @@ +import os +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.check_result import CheckResult -import os -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -28,9 +29,10 @@ class CoffeeMachineTest(UserErrorTest): """ def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/go/coffee_machine/stage1_ex/tests.py b/tests/projects/go/coffee_machine/stage1_ex/tests.py index a1afac92..0659a0c9 100644 --- a/tests/projects/go/coffee_machine/stage1_ex/tests.py +++ b/tests/projects/go/coffee_machine/stage1_ex/tests.py @@ -1,10 +1,11 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -29,9 +30,10 @@ class CoffeeMachineTest(UserErrorTest): """ def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/go/coffee_machine/stage1_wa/tests.py b/tests/projects/go/coffee_machine/stage1_wa/tests.py index cc4972a9..5fdf70bd 100644 --- a/tests/projects/go/coffee_machine/stage1_wa/tests.py +++ b/tests/projects/go/coffee_machine/stage1_wa/tests.py @@ -1,10 +1,11 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -32,9 +33,10 @@ class CoffeeMachineTest(UserErrorTest): """ def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/go/coffee_machine/stage2/tests.py b/tests/projects/go/coffee_machine/stage2/tests.py index 33564d63..11314142 100644 --- a/tests/projects/go/coffee_machine/stage2/tests.py +++ b/tests/projects/go/coffee_machine/stage2/tests.py @@ -1,21 +1,17 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( - [ - ('25', '25'), - ('125', '125'), - ('1', '1'), - ('123', '123') - ] + [("25", "25"), ("125", "125"), ("1", "1"), ("123", "123")] ) def check(self, reply: str, clue: Any) -> CheckResult: @@ -24,45 +20,46 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(lines) < 3: return CheckResult.wrong( - 'Output contains less than 3 lines, ' - 'but should output at least 3 lines') + "Output contains less than 3 lines, " + "but should output at least 3 lines" + ) last_3_lines = reply.splitlines()[-3:] cups = int(clue) water = milk = beans = False for line in last_3_lines: line = line.lower() - if 'milk' in line: + if "milk" in line: milk = str(cups * 50) in line if not milk: return CheckResult.wrong( - f"For the input {clue} your program output:\n\"" + - f"{line}\"\nbut the amount of milk should be {cups * 50}" + f'For the input {clue} your program output:\n"' + + f'{line}"\nbut the amount of milk should be {cups * 50}' ) - elif 'water' in line: + elif "water" in line: water = str(cups * 200) in line if not water: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of water should be {cups * 200}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of water should be {cups * 200}" ) - elif 'beans' in line: + elif "beans" in line: beans = str(cups * 15) in line if not beans: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of beans should be {cups * 15}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of beans should be {cups * 15}" ) else: return CheckResult.wrong( - "One of the last 3 lines " + - "doesn't contain \"milk\", \"water\" or \"beans\"" + "One of the last 3 lines " + + 'doesn\'t contain "milk", "water" or "beans"' ) if not water: diff --git a/tests/projects/go/coffee_machine/stage3/tests.py b/tests/projects/go/coffee_machine/stage3/tests.py index 9dd33dd0..04a5a4a8 100644 --- a/tests/projects/go/coffee_machine/stage3/tests.py +++ b/tests/projects/go/coffee_machine/stage3/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,28 +12,27 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( [ - ('300\n65\n111\n1\n', (True, 0, True)), - ('600\n153\n100\n1', (True, 2, True)), - ('1400\n150\n100\n1', (True, 2, True)), - ('1400\n1500\n45\n1', (True, 2, True)), - ('599\n250\n200\n10', (False, 2, True)), - ('34564\n43423\n23234\n1', (True, 171, True)), - ('345640\n434230\n23234\n1', (True, 1547, True)), - ('345640\n43423\n23234\n19246', (False, 868, True)), - - ('399\n112\n111\n1', (True, 0, False)), - ('2400\n249\n100\n1', (True, 3, False)), - ('1400\n1500\n44\n1', (True, 1, False)), - ('500\n250\n200\n10', (False, 2, False)), - ('600\n250\n200\n10', (False, 3, False)), - ('345640\n43423\n23234\n1', (True, 867, False)), - ('345640\n434230\n23234\n19246', (False, 1548, False)), - ('34564\n43423\n23234\n19246', (False, 172, False)), + ("300\n65\n111\n1\n", (True, 0, True)), + ("600\n153\n100\n1", (True, 2, True)), + ("1400\n150\n100\n1", (True, 2, True)), + ("1400\n1500\n45\n1", (True, 2, True)), + ("599\n250\n200\n10", (False, 2, True)), + ("34564\n43423\n23234\n1", (True, 171, True)), + ("345640\n434230\n23234\n1", (True, 1547, True)), + ("345640\n43423\n23234\n19246", (False, 868, True)), + ("399\n112\n111\n1", (True, 0, False)), + ("2400\n249\n100\n1", (True, 3, False)), + ("1400\n1500\n44\n1", (True, 1, False)), + ("500\n250\n200\n10", (False, 2, False)), + ("600\n250\n200\n10", (False, 3, False)), + ("345640\n43423\n23234\n1", (True, 867, False)), + ("345640\n434230\n23234\n19246", (False, 1548, False)), + ("34564\n43423\n23234\n19246", (False, 172, False)), ] ) def check(self, reply: str, clue: Any) -> CheckResult: - user_output = reply.split(':')[-1].strip() + user_output = reply.split(":")[-1].strip() lowered_output = user_output.lower() print("----") print(lowered_output) @@ -40,77 +40,70 @@ def check(self, reply: str, clue: Any) -> CheckResult: ans, amount, show_tests = clue if ans: if amount > 0: - is_correct = f'{amount}' in lowered_output and 'yes' in lowered_output + is_correct = f"{amount}" in lowered_output and "yes" in lowered_output if is_correct: - if f'{amount}.' in lowered_output: + if f"{amount}." in lowered_output: return CheckResult.wrong( "There is a dot after an amount of cups. " "There should be no dot.\n" - "Your output:\n" + - user_output + "Your output:\n" + user_output ) return CheckResult.correct() else: right_output = ( - "Yes, I can make that amount of coffee" + - f" (and even {amount} more than that)" + "Yes, I can make that amount of coffee" + + f" (and even {amount} more than that)" ) if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') - if 'yes, i can make that amount of coffee' == lowered_output: + return CheckResult.wrong("") + if "yes, i can make that amount of coffee" == lowered_output: return CheckResult.correct() else: - right_output = ( - "Yes, I can make that amount of coffee" - ) + right_output = "Yes, I can make that amount of coffee" if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') + return CheckResult.wrong("") else: - cond1 = 'no' in lowered_output + cond1 = "no" in lowered_output cond2 = str(amount) in lowered_output if cond1 and cond2: - if f'{amount}.' in lowered_output: + if f"{amount}." in lowered_output: return CheckResult.wrong( "There is a dot after an amount of cups. " "There should be no dot.\n" - "Your output:\n" + - user_output + "Your output:\n" + user_output ) return CheckResult.correct() else: - right_output = ( - "No, I can make only " + - f"{amount} cup(s) of coffee" - ) + right_output = "No, I can make only " + f"{amount} cup(s) of coffee" if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/projects/go/coffee_machine/stage4/tests.py b/tests/projects/go/coffee_machine/stage4/tests.py index 5b901da2..3dbf8d12 100644 --- a/tests/projects/go/coffee_machine/stage4/tests.py +++ b/tests/projects/go/coffee_machine/stage4/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,17 +12,17 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( [ - ('take\n',) * 2, - ('buy\n1\n',) * 2, - ('buy\n2\n',) * 2, - ('buy\n3\n',) * 2, - ('fill\n2001\n510\n101\n21\n',) * 2, + ("take\n",) * 2, + ("buy\n1\n",) * 2, + ("buy\n2\n",) * 2, + ("buy\n3\n",) * 2, + ("fill\n2001\n510\n101\n21\n",) * 2, ] ) def check(self, reply: str, clue: Any) -> CheckResult: if len(reply.splitlines()) <= 1: - return CheckResult.wrong('Too few output lines') + return CheckResult.wrong("Too few output lines") action, *rest = clue.split() @@ -35,49 +36,44 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(line.split()) == 0: continue first_word = line.split()[0] - first_word = first_word.replace('$', '') + first_word = first_word.replace("$", "") if not first_word.isdigit(): continue amount = int(first_word) - if 'milk' in line: - milk += amount, - elif 'water' in line: - water += amount, - elif 'beans' in line: - beans += amount, - elif 'cups' in line: - cups += amount, - elif 'money' in line: - money += amount, + if "milk" in line: + milk += (amount,) + elif "water" in line: + water += (amount,) + elif "beans" in line: + beans += (amount,) + elif "cups" in line: + cups += (amount,) + elif "money" in line: + money += (amount,) if len(milk) != 2: return CheckResult.wrong( - "There should be two lines with \"milk\", " + - f"found: {len(milk)}" + 'There should be two lines with "milk", ' + f"found: {len(milk)}" ) if len(water) != 2: return CheckResult.wrong( - "There should be two lines with \"water\", " + - f"found: {len(water)}" + 'There should be two lines with "water", ' + f"found: {len(water)}" ) if len(beans) != 2: return CheckResult.wrong( - "There should be two lines with \"beans\", " + - f"found: {len(beans)}" + 'There should be two lines with "beans", ' + f"found: {len(beans)}" ) if len(cups) != 2: return CheckResult.wrong( - "There should be two lines with \"cups\", " + - f"found: {len(cups)}" + 'There should be two lines with "cups", ' + f"found: {len(cups)}" ) if len(money) != 2: return CheckResult.wrong( - "There should be two lines with \"money\", " + - f"found: {len(money)}" + 'There should be two lines with "money", ' + f"found: {len(money)}" ) milk = milk[0], milk[-1] @@ -86,187 +82,187 @@ def check(self, reply: str, clue: Any) -> CheckResult: cups = cups[0], cups[-1] money = money[0], money[-1] - if water[0] != 400 or milk[0] != 540 or beans[0] != 120 or cups[0] != 9 or money[0] != 550: + if ( + water[0] != 400 + or milk[0] != 540 + or beans[0] != 120 + or cups[0] != 9 + or money[0] != 550 + ): return CheckResult.wrong( - "Initial setup is wrong: " + - "coffee machine should be filled like " + - "stated in the description" + "Initial setup is wrong: " + + "coffee machine should be filled like " + + "stated in the description" ) diff = lambda item: item[1] - item[0] - if action == 'take': + if action == "take": if diff(milk) != 0: return CheckResult.wrong( - "After \"take\" action milk " + - "amount shouldn't be changed" + 'After "take" action milk ' + "amount shouldn't be changed" ) if diff(water) != 0: return CheckResult.wrong( - "After \"take\" action water " + - "amount shouldn't be changed" + 'After "take" action water ' + "amount shouldn't be changed" ) if diff(beans) != 0: return CheckResult.wrong( - "After \"take\" action beans " + - "amount shouldn't be changed" + 'After "take" action beans ' + "amount shouldn't be changed" ) if diff(cups) != 0: return CheckResult.wrong( - "After \"take\" action cups " + - "amount shouldn't be changed" + 'After "take" action cups ' + "amount shouldn't be changed" ) if money[1] != 0: return CheckResult.wrong( - "After \"take\" action money " + - "amount should be zero" + 'After "take" action money ' + "amount should be zero" ) return CheckResult.correct() - elif action == 'buy': + elif action == "buy": option = rest[0] - if option == '1': + if option == "1": if diff(water) != -250: return CheckResult.wrong( - "After buying the first option " + - "water amount should be lowered by 250" + "After buying the first option " + + "water amount should be lowered by 250" ) if diff(milk) != 0: return CheckResult.wrong( - "After buying the first option " + - "milk amount should not be changed" + "After buying the first option " + + "milk amount should not be changed" ) if diff(beans) != -16: return CheckResult.wrong( - "After buying the first option " + - "beans amount should be lowered by 16" + "After buying the first option " + + "beans amount should be lowered by 16" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the first option " + - "cups amount should be lowered by 1" + "After buying the first option " + + "cups amount should be lowered by 1" ) if diff(money) != 4: return CheckResult.wrong( - "After buying the first option " + - "money amount should be increased by 4" + "After buying the first option " + + "money amount should be increased by 4" ) return CheckResult.correct() - elif option == '2': + elif option == "2": if diff(water) != -350: return CheckResult.wrong( - "After buying the second option " + - "water amount should be lowered by 350" + "After buying the second option " + + "water amount should be lowered by 350" ) if diff(milk) != -75: return CheckResult.wrong( - "After buying the second option " + - "milk amount should be lowered by 75" + "After buying the second option " + + "milk amount should be lowered by 75" ) if diff(beans) != -20: return CheckResult.wrong( - "After buying the second option " + - "beans amount should be lowered by 20" + "After buying the second option " + + "beans amount should be lowered by 20" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the second option " + - "cups amount should be lowered by 1" + "After buying the second option " + + "cups amount should be lowered by 1" ) if diff(money) != 7: return CheckResult.wrong( - "After buying the second option " + - "money amount should be increased by 7" + "After buying the second option " + + "money amount should be increased by 7" ) return CheckResult.correct() - elif option == '3': + elif option == "3": if diff(water) != -200: return CheckResult.wrong( - "After buying the third option " + - "water amount should be lowered by 200" + "After buying the third option " + + "water amount should be lowered by 200" ) if diff(milk) != -100: return CheckResult.wrong( - "After buying the third option " + - "milk amount should be lowered by 100" + "After buying the third option " + + "milk amount should be lowered by 100" ) if diff(beans) != -12: return CheckResult.wrong( - "After buying the third option " + - "beans amount should be lowered by 12" + "After buying the third option " + + "beans amount should be lowered by 12" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the third option " + - "cups amount should be lowered by 1" + "After buying the third option " + + "cups amount should be lowered by 1" ) if diff(money) != 6: return CheckResult.wrong( - "After buying the third option " + - "money amount should be increased by 6" + "After buying the third option " + + "money amount should be increased by 6" ) return CheckResult.correct() - elif action == 'fill': + elif action == "fill": water_, milk_, beans_, cups_ = map(int, rest) if diff(money) != 0: return CheckResult.wrong( - "After \"fill\" action " + - "money amount should not be changed" + 'After "fill" action ' + "money amount should not be changed" ) if diff(water) != water_: return CheckResult.wrong( - "After \"fill\" action " + - f"water amount expected to be increased by {water_}" + - f" but was increased by {diff(water)}" + 'After "fill" action ' + + f"water amount expected to be increased by {water_}" + + f" but was increased by {diff(water)}" ) if diff(milk) != milk_: return CheckResult.wrong( - "After \"fill\" action " + - f"milk amount expected to be increased by {milk_}" + - f" but was increased by {diff(milk)}" + 'After "fill" action ' + + f"milk amount expected to be increased by {milk_}" + + f" but was increased by {diff(milk)}" ) if diff(beans) != beans_: return CheckResult.wrong( - "After \"fill\" action " + - f"beans amount expected to be increased by {beans_}" + - f" but was increased by {diff(beans)}" + 'After "fill" action ' + + f"beans amount expected to be increased by {beans_}" + + f" but was increased by {diff(beans)}" ) if diff(cups) != cups_: return CheckResult.wrong( - "After \"fill\" action " + - f"cups amount expected to be increased by {cups_}" + - f" but was increased by {diff(cups)}" + 'After "fill" action ' + + f"cups amount expected to be increased by {cups_}" + + f" but was increased by {diff(cups)}" ) return CheckResult.correct() diff --git a/tests/projects/go/coffee_machine/stage5/tests.py b/tests/projects/go/coffee_machine/stage5/tests.py index 37c309a9..4012e103 100644 --- a/tests/projects/go/coffee_machine/stage5/tests.py +++ b/tests/projects/go/coffee_machine/stage5/tests.py @@ -1,12 +1,13 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) -test1_input = '''remaining +test1_input = """remaining buy 2 buy @@ -21,9 +22,9 @@ take remaining exit -''' +""" -test2_input = '''remaining +test2_input = """remaining fill 3000 3000 @@ -31,41 +32,41 @@ 3000 remaining exit -''' +""" -test3_input = '''remaining +test3_input = """remaining buy 1 remaining exit -''' +""" -test4_input = '''remaining +test4_input = """remaining buy 2 remaining exit -''' +""" -test5_input = '''remaining +test5_input = """remaining buy 3 remaining exit -''' +""" -test6_input = '''remaining +test6_input = """remaining take remaining exit -''' +""" -test7_input = '''remaining +test7_input = """remaining buy back remaining exit -''' +""" class CoffeeMachineTest(StageTest): @@ -81,22 +82,13 @@ def generate(self) -> List[TestCase]: 7 - 9, 0 - 550, "This test is exactly like in the example " - "- try to run it by yourself" - ) + "- try to run it by yourself", + ), ), - ( test2_input, - ( - 3000, - 3000, - 3000, - 3000, - 0, - "This test checks \"fill\" action" - ) + (3000, 3000, 3000, 3000, 0, 'This test checks "fill" action'), ), - ( test3_input, ( @@ -105,11 +97,10 @@ def generate(self) -> List[TestCase]: -16, -1, 4, - "This test checks \"buy\" " + - "action with the first variant of coffee" - ) + 'This test checks "buy" ' + + "action with the first variant of coffee", + ), ), - ( test4_input, ( @@ -118,11 +109,10 @@ def generate(self) -> List[TestCase]: -20, -1, 7, - "This test checks \"buy\" " + - "action with the second variant of coffee" - ) + 'This test checks "buy" ' + + "action with the second variant of coffee", + ), ), - ( test5_input, ( @@ -131,22 +121,11 @@ def generate(self) -> List[TestCase]: -12, -1, 6, - "This test checks \"buy\" " + - "action with the third variant of coffee" - ) + 'This test checks "buy" ' + + "action with the third variant of coffee", + ), ), - ( - test6_input, - ( - 0, - 0, - 0, - 0, - -550, - "This test checks \"take\" action" - ) - ), - + (test6_input, (0, 0, 0, 0, -550, 'This test checks "take" action')), ( test7_input, ( @@ -155,16 +134,15 @@ def generate(self) -> List[TestCase]: 0, 0, 0, - "This test checks \"back\" " + - "action right after \"buy\" action" - ) + 'This test checks "back" ' + 'action right after "buy" action', + ), ), ] ) def check(self, reply: str, clue: Any) -> CheckResult: if len(reply.splitlines()) <= 1: - return CheckResult.wrong('Too few lines in output') + return CheckResult.wrong("Too few lines in output") water_, milk_, beans_, cups_, money_, feedback = clue @@ -175,52 +153,47 @@ def check(self, reply: str, clue: Any) -> CheckResult: money = [] for line in reply.splitlines(): - line = line.replace('$', '').strip() + line = line.replace("$", "").strip() if len(line.split()) == 0: continue first_word = line.split()[0] if not first_word.isdigit(): continue amount = int(first_word) - if 'milk' in line: - milk += amount, - elif 'water' in line: - water += amount, - elif 'beans' in line: - beans += amount, - elif 'cups' in line: - cups += amount, - elif 'money' in line or 'cash' in line: - money += amount, + if "milk" in line: + milk += (amount,) + elif "water" in line: + water += (amount,) + elif "beans" in line: + beans += (amount,) + elif "cups" in line: + cups += (amount,) + elif "money" in line or "cash" in line: + money += (amount,) if len(milk) != 2: return CheckResult.wrong( - "There should be two lines with \"milk\", " + - f"found: {len(milk)}" + 'There should be two lines with "milk", ' + f"found: {len(milk)}" ) if len(water) != 2: return CheckResult.wrong( - "There should be two lines with \"water\", " + - f"found: {len(water)}" + 'There should be two lines with "water", ' + f"found: {len(water)}" ) if len(beans) != 2: return CheckResult.wrong( - "There should be two lines with \"beans\", " + - f"found: {len(beans)}" + 'There should be two lines with "beans", ' + f"found: {len(beans)}" ) if len(cups) != 2: return CheckResult.wrong( - "There should be two lines with \"cups\", " + - f"found: {len(cups)}" + 'There should be two lines with "cups", ' + f"found: {len(cups)}" ) if len(money) != 2: return CheckResult.wrong( - "There should be two lines with \"money\", " + - f"found: {len(money)}" + 'There should be two lines with "money", ' + f"found: {len(money)}" ) milk = milk[0], milk[-1] @@ -232,10 +205,10 @@ def check(self, reply: str, clue: Any) -> CheckResult: diff = lambda item: item[1] - item[0] is_correct = ( - diff(water) == water_ and - diff(milk) == milk_ and - diff(beans) == beans_ and - diff(cups) == cups_ and - diff(money) == money_ + diff(water) == water_ + and diff(milk) == milk_ + and diff(beans) == beans_ + and diff(cups) == cups_ + and diff(money) == money_ ) return CheckResult(is_correct, feedback) diff --git a/tests/projects/javascript/coffee_machine/stage1/tests.py b/tests/projects/javascript/coffee_machine/stage1/tests.py index 947ca431..f236699c 100644 --- a/tests/projects/javascript/coffee_machine/stage1/tests.py +++ b/tests/projects/javascript/coffee_machine/stage1/tests.py @@ -1,10 +1,10 @@ from typing import List +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -20,9 +20,10 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/javascript/coffee_machine/stage1_ce/tests.py b/tests/projects/javascript/coffee_machine/stage1_ce/tests.py index 4c6381d4..7205d0a1 100644 --- a/tests/projects/javascript/coffee_machine/stage1_ce/tests.py +++ b/tests/projects/javascript/coffee_machine/stage1_ce/tests.py @@ -1,11 +1,11 @@ from typing import List +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.check_result import CheckResult -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -21,20 +21,21 @@ class CoffeeMachineTest(UserErrorTest): contain = [ - 'Exception in test #1', + "Exception in test #1", r""" main.js:2 console.log(`Starting to make a coffee """, - 'SyntaxError: missing ) after argument list' + "SyntaxError: missing ) after argument list", ] - not_contain = 'Traceback' + not_contain = "Traceback" def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/javascript/coffee_machine/stage1_ex/tests.py b/tests/projects/javascript/coffee_machine/stage1_ex/tests.py index 7e09982d..41510e19 100644 --- a/tests/projects/javascript/coffee_machine/stage1_ex/tests.py +++ b/tests/projects/javascript/coffee_machine/stage1_ex/tests.py @@ -1,10 +1,11 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -19,23 +20,24 @@ class CoffeeMachineTest(UserErrorTest): - not_contain = 'Traceback' + not_contain = "Traceback" contain = [ - 'Exception in test #1', - r''' + "Exception in test #1", + r""" main.js:2 console.log(0 .valueOf1()) ^ TypeError: 0.valueOf1 is not a function - ''' + """, ] def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/javascript/coffee_machine/stage1_wa/tests.py b/tests/projects/javascript/coffee_machine/stage1_wa/tests.py index cc4972a9..5fdf70bd 100644 --- a/tests/projects/javascript/coffee_machine/stage1_wa/tests.py +++ b/tests/projects/javascript/coffee_machine/stage1_wa/tests.py @@ -1,10 +1,11 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -32,9 +33,10 @@ class CoffeeMachineTest(UserErrorTest): """ def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/javascript/coffee_machine/stage2/tests.py b/tests/projects/javascript/coffee_machine/stage2/tests.py index 33564d63..11314142 100644 --- a/tests/projects/javascript/coffee_machine/stage2/tests.py +++ b/tests/projects/javascript/coffee_machine/stage2/tests.py @@ -1,21 +1,17 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( - [ - ('25', '25'), - ('125', '125'), - ('1', '1'), - ('123', '123') - ] + [("25", "25"), ("125", "125"), ("1", "1"), ("123", "123")] ) def check(self, reply: str, clue: Any) -> CheckResult: @@ -24,45 +20,46 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(lines) < 3: return CheckResult.wrong( - 'Output contains less than 3 lines, ' - 'but should output at least 3 lines') + "Output contains less than 3 lines, " + "but should output at least 3 lines" + ) last_3_lines = reply.splitlines()[-3:] cups = int(clue) water = milk = beans = False for line in last_3_lines: line = line.lower() - if 'milk' in line: + if "milk" in line: milk = str(cups * 50) in line if not milk: return CheckResult.wrong( - f"For the input {clue} your program output:\n\"" + - f"{line}\"\nbut the amount of milk should be {cups * 50}" + f'For the input {clue} your program output:\n"' + + f'{line}"\nbut the amount of milk should be {cups * 50}' ) - elif 'water' in line: + elif "water" in line: water = str(cups * 200) in line if not water: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of water should be {cups * 200}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of water should be {cups * 200}" ) - elif 'beans' in line: + elif "beans" in line: beans = str(cups * 15) in line if not beans: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of beans should be {cups * 15}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of beans should be {cups * 15}" ) else: return CheckResult.wrong( - "One of the last 3 lines " + - "doesn't contain \"milk\", \"water\" or \"beans\"" + "One of the last 3 lines " + + 'doesn\'t contain "milk", "water" or "beans"' ) if not water: diff --git a/tests/projects/javascript/coffee_machine/stage3/tests.py b/tests/projects/javascript/coffee_machine/stage3/tests.py index 9dd33dd0..04a5a4a8 100644 --- a/tests/projects/javascript/coffee_machine/stage3/tests.py +++ b/tests/projects/javascript/coffee_machine/stage3/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,28 +12,27 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( [ - ('300\n65\n111\n1\n', (True, 0, True)), - ('600\n153\n100\n1', (True, 2, True)), - ('1400\n150\n100\n1', (True, 2, True)), - ('1400\n1500\n45\n1', (True, 2, True)), - ('599\n250\n200\n10', (False, 2, True)), - ('34564\n43423\n23234\n1', (True, 171, True)), - ('345640\n434230\n23234\n1', (True, 1547, True)), - ('345640\n43423\n23234\n19246', (False, 868, True)), - - ('399\n112\n111\n1', (True, 0, False)), - ('2400\n249\n100\n1', (True, 3, False)), - ('1400\n1500\n44\n1', (True, 1, False)), - ('500\n250\n200\n10', (False, 2, False)), - ('600\n250\n200\n10', (False, 3, False)), - ('345640\n43423\n23234\n1', (True, 867, False)), - ('345640\n434230\n23234\n19246', (False, 1548, False)), - ('34564\n43423\n23234\n19246', (False, 172, False)), + ("300\n65\n111\n1\n", (True, 0, True)), + ("600\n153\n100\n1", (True, 2, True)), + ("1400\n150\n100\n1", (True, 2, True)), + ("1400\n1500\n45\n1", (True, 2, True)), + ("599\n250\n200\n10", (False, 2, True)), + ("34564\n43423\n23234\n1", (True, 171, True)), + ("345640\n434230\n23234\n1", (True, 1547, True)), + ("345640\n43423\n23234\n19246", (False, 868, True)), + ("399\n112\n111\n1", (True, 0, False)), + ("2400\n249\n100\n1", (True, 3, False)), + ("1400\n1500\n44\n1", (True, 1, False)), + ("500\n250\n200\n10", (False, 2, False)), + ("600\n250\n200\n10", (False, 3, False)), + ("345640\n43423\n23234\n1", (True, 867, False)), + ("345640\n434230\n23234\n19246", (False, 1548, False)), + ("34564\n43423\n23234\n19246", (False, 172, False)), ] ) def check(self, reply: str, clue: Any) -> CheckResult: - user_output = reply.split(':')[-1].strip() + user_output = reply.split(":")[-1].strip() lowered_output = user_output.lower() print("----") print(lowered_output) @@ -40,77 +40,70 @@ def check(self, reply: str, clue: Any) -> CheckResult: ans, amount, show_tests = clue if ans: if amount > 0: - is_correct = f'{amount}' in lowered_output and 'yes' in lowered_output + is_correct = f"{amount}" in lowered_output and "yes" in lowered_output if is_correct: - if f'{amount}.' in lowered_output: + if f"{amount}." in lowered_output: return CheckResult.wrong( "There is a dot after an amount of cups. " "There should be no dot.\n" - "Your output:\n" + - user_output + "Your output:\n" + user_output ) return CheckResult.correct() else: right_output = ( - "Yes, I can make that amount of coffee" + - f" (and even {amount} more than that)" + "Yes, I can make that amount of coffee" + + f" (and even {amount} more than that)" ) if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') - if 'yes, i can make that amount of coffee' == lowered_output: + return CheckResult.wrong("") + if "yes, i can make that amount of coffee" == lowered_output: return CheckResult.correct() else: - right_output = ( - "Yes, I can make that amount of coffee" - ) + right_output = "Yes, I can make that amount of coffee" if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') + return CheckResult.wrong("") else: - cond1 = 'no' in lowered_output + cond1 = "no" in lowered_output cond2 = str(amount) in lowered_output if cond1 and cond2: - if f'{amount}.' in lowered_output: + if f"{amount}." in lowered_output: return CheckResult.wrong( "There is a dot after an amount of cups. " "There should be no dot.\n" - "Your output:\n" + - user_output + "Your output:\n" + user_output ) return CheckResult.correct() else: - right_output = ( - "No, I can make only " + - f"{amount} cup(s) of coffee" - ) + right_output = "No, I can make only " + f"{amount} cup(s) of coffee" if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/projects/javascript/coffee_machine/stage4/tests.py b/tests/projects/javascript/coffee_machine/stage4/tests.py index 5b901da2..3dbf8d12 100644 --- a/tests/projects/javascript/coffee_machine/stage4/tests.py +++ b/tests/projects/javascript/coffee_machine/stage4/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,17 +12,17 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( [ - ('take\n',) * 2, - ('buy\n1\n',) * 2, - ('buy\n2\n',) * 2, - ('buy\n3\n',) * 2, - ('fill\n2001\n510\n101\n21\n',) * 2, + ("take\n",) * 2, + ("buy\n1\n",) * 2, + ("buy\n2\n",) * 2, + ("buy\n3\n",) * 2, + ("fill\n2001\n510\n101\n21\n",) * 2, ] ) def check(self, reply: str, clue: Any) -> CheckResult: if len(reply.splitlines()) <= 1: - return CheckResult.wrong('Too few output lines') + return CheckResult.wrong("Too few output lines") action, *rest = clue.split() @@ -35,49 +36,44 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(line.split()) == 0: continue first_word = line.split()[0] - first_word = first_word.replace('$', '') + first_word = first_word.replace("$", "") if not first_word.isdigit(): continue amount = int(first_word) - if 'milk' in line: - milk += amount, - elif 'water' in line: - water += amount, - elif 'beans' in line: - beans += amount, - elif 'cups' in line: - cups += amount, - elif 'money' in line: - money += amount, + if "milk" in line: + milk += (amount,) + elif "water" in line: + water += (amount,) + elif "beans" in line: + beans += (amount,) + elif "cups" in line: + cups += (amount,) + elif "money" in line: + money += (amount,) if len(milk) != 2: return CheckResult.wrong( - "There should be two lines with \"milk\", " + - f"found: {len(milk)}" + 'There should be two lines with "milk", ' + f"found: {len(milk)}" ) if len(water) != 2: return CheckResult.wrong( - "There should be two lines with \"water\", " + - f"found: {len(water)}" + 'There should be two lines with "water", ' + f"found: {len(water)}" ) if len(beans) != 2: return CheckResult.wrong( - "There should be two lines with \"beans\", " + - f"found: {len(beans)}" + 'There should be two lines with "beans", ' + f"found: {len(beans)}" ) if len(cups) != 2: return CheckResult.wrong( - "There should be two lines with \"cups\", " + - f"found: {len(cups)}" + 'There should be two lines with "cups", ' + f"found: {len(cups)}" ) if len(money) != 2: return CheckResult.wrong( - "There should be two lines with \"money\", " + - f"found: {len(money)}" + 'There should be two lines with "money", ' + f"found: {len(money)}" ) milk = milk[0], milk[-1] @@ -86,187 +82,187 @@ def check(self, reply: str, clue: Any) -> CheckResult: cups = cups[0], cups[-1] money = money[0], money[-1] - if water[0] != 400 or milk[0] != 540 or beans[0] != 120 or cups[0] != 9 or money[0] != 550: + if ( + water[0] != 400 + or milk[0] != 540 + or beans[0] != 120 + or cups[0] != 9 + or money[0] != 550 + ): return CheckResult.wrong( - "Initial setup is wrong: " + - "coffee machine should be filled like " + - "stated in the description" + "Initial setup is wrong: " + + "coffee machine should be filled like " + + "stated in the description" ) diff = lambda item: item[1] - item[0] - if action == 'take': + if action == "take": if diff(milk) != 0: return CheckResult.wrong( - "After \"take\" action milk " + - "amount shouldn't be changed" + 'After "take" action milk ' + "amount shouldn't be changed" ) if diff(water) != 0: return CheckResult.wrong( - "After \"take\" action water " + - "amount shouldn't be changed" + 'After "take" action water ' + "amount shouldn't be changed" ) if diff(beans) != 0: return CheckResult.wrong( - "After \"take\" action beans " + - "amount shouldn't be changed" + 'After "take" action beans ' + "amount shouldn't be changed" ) if diff(cups) != 0: return CheckResult.wrong( - "After \"take\" action cups " + - "amount shouldn't be changed" + 'After "take" action cups ' + "amount shouldn't be changed" ) if money[1] != 0: return CheckResult.wrong( - "After \"take\" action money " + - "amount should be zero" + 'After "take" action money ' + "amount should be zero" ) return CheckResult.correct() - elif action == 'buy': + elif action == "buy": option = rest[0] - if option == '1': + if option == "1": if diff(water) != -250: return CheckResult.wrong( - "After buying the first option " + - "water amount should be lowered by 250" + "After buying the first option " + + "water amount should be lowered by 250" ) if diff(milk) != 0: return CheckResult.wrong( - "After buying the first option " + - "milk amount should not be changed" + "After buying the first option " + + "milk amount should not be changed" ) if diff(beans) != -16: return CheckResult.wrong( - "After buying the first option " + - "beans amount should be lowered by 16" + "After buying the first option " + + "beans amount should be lowered by 16" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the first option " + - "cups amount should be lowered by 1" + "After buying the first option " + + "cups amount should be lowered by 1" ) if diff(money) != 4: return CheckResult.wrong( - "After buying the first option " + - "money amount should be increased by 4" + "After buying the first option " + + "money amount should be increased by 4" ) return CheckResult.correct() - elif option == '2': + elif option == "2": if diff(water) != -350: return CheckResult.wrong( - "After buying the second option " + - "water amount should be lowered by 350" + "After buying the second option " + + "water amount should be lowered by 350" ) if diff(milk) != -75: return CheckResult.wrong( - "After buying the second option " + - "milk amount should be lowered by 75" + "After buying the second option " + + "milk amount should be lowered by 75" ) if diff(beans) != -20: return CheckResult.wrong( - "After buying the second option " + - "beans amount should be lowered by 20" + "After buying the second option " + + "beans amount should be lowered by 20" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the second option " + - "cups amount should be lowered by 1" + "After buying the second option " + + "cups amount should be lowered by 1" ) if diff(money) != 7: return CheckResult.wrong( - "After buying the second option " + - "money amount should be increased by 7" + "After buying the second option " + + "money amount should be increased by 7" ) return CheckResult.correct() - elif option == '3': + elif option == "3": if diff(water) != -200: return CheckResult.wrong( - "After buying the third option " + - "water amount should be lowered by 200" + "After buying the third option " + + "water amount should be lowered by 200" ) if diff(milk) != -100: return CheckResult.wrong( - "After buying the third option " + - "milk amount should be lowered by 100" + "After buying the third option " + + "milk amount should be lowered by 100" ) if diff(beans) != -12: return CheckResult.wrong( - "After buying the third option " + - "beans amount should be lowered by 12" + "After buying the third option " + + "beans amount should be lowered by 12" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the third option " + - "cups amount should be lowered by 1" + "After buying the third option " + + "cups amount should be lowered by 1" ) if diff(money) != 6: return CheckResult.wrong( - "After buying the third option " + - "money amount should be increased by 6" + "After buying the third option " + + "money amount should be increased by 6" ) return CheckResult.correct() - elif action == 'fill': + elif action == "fill": water_, milk_, beans_, cups_ = map(int, rest) if diff(money) != 0: return CheckResult.wrong( - "After \"fill\" action " + - "money amount should not be changed" + 'After "fill" action ' + "money amount should not be changed" ) if diff(water) != water_: return CheckResult.wrong( - "After \"fill\" action " + - f"water amount expected to be increased by {water_}" + - f" but was increased by {diff(water)}" + 'After "fill" action ' + + f"water amount expected to be increased by {water_}" + + f" but was increased by {diff(water)}" ) if diff(milk) != milk_: return CheckResult.wrong( - "After \"fill\" action " + - f"milk amount expected to be increased by {milk_}" + - f" but was increased by {diff(milk)}" + 'After "fill" action ' + + f"milk amount expected to be increased by {milk_}" + + f" but was increased by {diff(milk)}" ) if diff(beans) != beans_: return CheckResult.wrong( - "After \"fill\" action " + - f"beans amount expected to be increased by {beans_}" + - f" but was increased by {diff(beans)}" + 'After "fill" action ' + + f"beans amount expected to be increased by {beans_}" + + f" but was increased by {diff(beans)}" ) if diff(cups) != cups_: return CheckResult.wrong( - "After \"fill\" action " + - f"cups amount expected to be increased by {cups_}" + - f" but was increased by {diff(cups)}" + 'After "fill" action ' + + f"cups amount expected to be increased by {cups_}" + + f" but was increased by {diff(cups)}" ) return CheckResult.correct() diff --git a/tests/projects/javascript/coffee_machine/stage5/tests.py b/tests/projects/javascript/coffee_machine/stage5/tests.py index 37c309a9..4012e103 100644 --- a/tests/projects/javascript/coffee_machine/stage5/tests.py +++ b/tests/projects/javascript/coffee_machine/stage5/tests.py @@ -1,12 +1,13 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) -test1_input = '''remaining +test1_input = """remaining buy 2 buy @@ -21,9 +22,9 @@ take remaining exit -''' +""" -test2_input = '''remaining +test2_input = """remaining fill 3000 3000 @@ -31,41 +32,41 @@ 3000 remaining exit -''' +""" -test3_input = '''remaining +test3_input = """remaining buy 1 remaining exit -''' +""" -test4_input = '''remaining +test4_input = """remaining buy 2 remaining exit -''' +""" -test5_input = '''remaining +test5_input = """remaining buy 3 remaining exit -''' +""" -test6_input = '''remaining +test6_input = """remaining take remaining exit -''' +""" -test7_input = '''remaining +test7_input = """remaining buy back remaining exit -''' +""" class CoffeeMachineTest(StageTest): @@ -81,22 +82,13 @@ def generate(self) -> List[TestCase]: 7 - 9, 0 - 550, "This test is exactly like in the example " - "- try to run it by yourself" - ) + "- try to run it by yourself", + ), ), - ( test2_input, - ( - 3000, - 3000, - 3000, - 3000, - 0, - "This test checks \"fill\" action" - ) + (3000, 3000, 3000, 3000, 0, 'This test checks "fill" action'), ), - ( test3_input, ( @@ -105,11 +97,10 @@ def generate(self) -> List[TestCase]: -16, -1, 4, - "This test checks \"buy\" " + - "action with the first variant of coffee" - ) + 'This test checks "buy" ' + + "action with the first variant of coffee", + ), ), - ( test4_input, ( @@ -118,11 +109,10 @@ def generate(self) -> List[TestCase]: -20, -1, 7, - "This test checks \"buy\" " + - "action with the second variant of coffee" - ) + 'This test checks "buy" ' + + "action with the second variant of coffee", + ), ), - ( test5_input, ( @@ -131,22 +121,11 @@ def generate(self) -> List[TestCase]: -12, -1, 6, - "This test checks \"buy\" " + - "action with the third variant of coffee" - ) + 'This test checks "buy" ' + + "action with the third variant of coffee", + ), ), - ( - test6_input, - ( - 0, - 0, - 0, - 0, - -550, - "This test checks \"take\" action" - ) - ), - + (test6_input, (0, 0, 0, 0, -550, 'This test checks "take" action')), ( test7_input, ( @@ -155,16 +134,15 @@ def generate(self) -> List[TestCase]: 0, 0, 0, - "This test checks \"back\" " + - "action right after \"buy\" action" - ) + 'This test checks "back" ' + 'action right after "buy" action', + ), ), ] ) def check(self, reply: str, clue: Any) -> CheckResult: if len(reply.splitlines()) <= 1: - return CheckResult.wrong('Too few lines in output') + return CheckResult.wrong("Too few lines in output") water_, milk_, beans_, cups_, money_, feedback = clue @@ -175,52 +153,47 @@ def check(self, reply: str, clue: Any) -> CheckResult: money = [] for line in reply.splitlines(): - line = line.replace('$', '').strip() + line = line.replace("$", "").strip() if len(line.split()) == 0: continue first_word = line.split()[0] if not first_word.isdigit(): continue amount = int(first_word) - if 'milk' in line: - milk += amount, - elif 'water' in line: - water += amount, - elif 'beans' in line: - beans += amount, - elif 'cups' in line: - cups += amount, - elif 'money' in line or 'cash' in line: - money += amount, + if "milk" in line: + milk += (amount,) + elif "water" in line: + water += (amount,) + elif "beans" in line: + beans += (amount,) + elif "cups" in line: + cups += (amount,) + elif "money" in line or "cash" in line: + money += (amount,) if len(milk) != 2: return CheckResult.wrong( - "There should be two lines with \"milk\", " + - f"found: {len(milk)}" + 'There should be two lines with "milk", ' + f"found: {len(milk)}" ) if len(water) != 2: return CheckResult.wrong( - "There should be two lines with \"water\", " + - f"found: {len(water)}" + 'There should be two lines with "water", ' + f"found: {len(water)}" ) if len(beans) != 2: return CheckResult.wrong( - "There should be two lines with \"beans\", " + - f"found: {len(beans)}" + 'There should be two lines with "beans", ' + f"found: {len(beans)}" ) if len(cups) != 2: return CheckResult.wrong( - "There should be two lines with \"cups\", " + - f"found: {len(cups)}" + 'There should be two lines with "cups", ' + f"found: {len(cups)}" ) if len(money) != 2: return CheckResult.wrong( - "There should be two lines with \"money\", " + - f"found: {len(money)}" + 'There should be two lines with "money", ' + f"found: {len(money)}" ) milk = milk[0], milk[-1] @@ -232,10 +205,10 @@ def check(self, reply: str, clue: Any) -> CheckResult: diff = lambda item: item[1] - item[0] is_correct = ( - diff(water) == water_ and - diff(milk) == milk_ and - diff(beans) == beans_ and - diff(cups) == cups_ and - diff(money) == money_ + diff(water) == water_ + and diff(milk) == milk_ + and diff(beans) == beans_ + and diff(cups) == cups_ + and diff(money) == money_ ) return CheckResult(is_correct, feedback) diff --git a/tests/projects/javascript/simple_chatty_bot/stage1/tests.py b/tests/projects/javascript/simple_chatty_bot/stage1/tests.py index ee283359..9f52bf07 100644 --- a/tests/projects/javascript/simple_chatty_bot/stage1/tests.py +++ b/tests/projects/javascript/simple_chatty_bot/stage1/tests.py @@ -1,11 +1,11 @@ import re +from typing import List +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -17,16 +17,17 @@ def check(self, reply: str, clue: Any) -> CheckResult: lines = reply.strip().splitlines() if len(lines) != 2: return CheckResult.wrong( - "You should output exactly 2 lines!\n" + - f"Lines found: {len(lines)}" + "You should output exactly 2 lines!\n" + f"Lines found: {len(lines)}" f"Your output:\n" f"{reply.strip()}" ) if not re.match(".*\\d.*", lines[1]): return CheckResult.wrong( - "The second line should contain a year!\n" + - "Your second line: \"" + lines[1] + "\"" + "The second line should contain a year!\n" + + 'Your second line: "' + + lines[1] + + '"' ) return CheckResult.correct() diff --git a/tests/projects/javascript/simple_chatty_bot/stage2/tests.py b/tests/projects/javascript/simple_chatty_bot/stage2/tests.py index c39604dc..17140461 100644 --- a/tests/projects/javascript/simple_chatty_bot/stage2/tests.py +++ b/tests/projects/javascript/simple_chatty_bot/stage2/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,15 +12,14 @@ class ChattyBotTest(StageTest): def generate(self) -> List[TestCase]: return [ TestCase(stdin="John", attach="John"), - TestCase(stdin="Nick", attach="Nick") + TestCase(stdin="Nick", attach="Nick"), ] def check(self, reply: str, clue: Any) -> CheckResult: lines = reply.strip().splitlines() if len(lines) != 4: return CheckResult.wrong( - "You should output 4 lines!\n" + - f"Lines found: {len(lines)}" + "You should output 4 lines!\n" + f"Lines found: {len(lines)}" f"Your output:\n" f"{reply.strip()}" ) @@ -29,10 +29,14 @@ def check(self, reply: str, clue: Any) -> CheckResult: if name not in line_with_name: return CheckResult.wrong( - "The name was " + clue + "\n" + - "But the 4-th line was:\n" + - "\"" + lines[3] + "\"\n\n" + - "4-th line should contain a name of the user" + "The name was " + + clue + + "\n" + + "But the 4-th line was:\n" + + '"' + + lines[3] + + '"\n\n' + + "4-th line should contain a name of the user" ) return CheckResult.correct() diff --git a/tests/projects/javascript/simple_chatty_bot/stage3/tests.py b/tests/projects/javascript/simple_chatty_bot/stage3/tests.py index e47e845f..b84ddfa9 100644 --- a/tests/projects/javascript/simple_chatty_bot/stage3/tests.py +++ b/tests/projects/javascript/simple_chatty_bot/stage3/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,15 +12,14 @@ class ChattyBotTest(StageTest): def generate(self) -> List[TestCase]: return [ TestCase(stdin="John\n1\n2\n1", attach=("John", 22)), - TestCase(stdin="Nick\n2\n0\n0", attach=("Nick", 35)) + TestCase(stdin="Nick\n2\n0\n0", attach=("Nick", 35)), ] def check(self, reply: str, clue: Any) -> CheckResult: lines = reply.strip().splitlines() if len(lines) != 7: return CheckResult.wrong( - "You should output 7 lines!\n" + - f"Lines found: {len(lines)}" + "You should output 7 lines!\n" + f"Lines found: {len(lines)}" f"Your output:\n" f"{reply.strip()}" ) @@ -29,10 +29,14 @@ def check(self, reply: str, clue: Any) -> CheckResult: if name not in line_with_name: return CheckResult.wrong( - "The name was " + clue[0] + "\n" + - "But the 4-th line was:\n" + - "\"" + lines[3] + "\"\n\n" + - "4-th line should contain a name of the user" + "The name was " + + clue[0] + + "\n" + + "But the 4-th line was:\n" + + '"' + + lines[3] + + '"\n\n' + + "4-th line should contain a name of the user" ) line_with_age = lines[6].lower() @@ -40,10 +44,13 @@ def check(self, reply: str, clue: Any) -> CheckResult: if age not in line_with_age: return CheckResult.wrong( - "Can't find a correct age " + - "in the last line of output! " + - "Maybe you calculated the age wrong?\n\n" + - "Your last line: \n" + "\"" + lines[6] + "\"" + "Can't find a correct age " + + "in the last line of output! " + + "Maybe you calculated the age wrong?\n\n" + + "Your last line: \n" + + '"' + + lines[6] + + '"' ) return CheckResult.correct() diff --git a/tests/projects/javascript/simple_chatty_bot/stage4/tests.py b/tests/projects/javascript/simple_chatty_bot/stage4/tests.py index dd871809..cd71ee4f 100644 --- a/tests/projects/javascript/simple_chatty_bot/stage4/tests.py +++ b/tests/projects/javascript/simple_chatty_bot/stage4/tests.py @@ -1,26 +1,25 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) class ChattyBotTest(StageTest): def generate(self) -> List[TestCase]: - return [ - TestCase(stdin="Marry\n1\n0\n5\n10", attach=("Marry", 40, 10)) - ] + return [TestCase(stdin="Marry\n1\n0\n5\n10", attach=("Marry", 40, 10))] def check(self, reply: str, clue: Any) -> CheckResult: lines = reply.strip().splitlines() length = 9 + clue[2] + 1 if len(lines) != length: return CheckResult.wrong( - f"You should output {length} lines " + - f"(for the count number {clue[2]}).\n" + - f"Lines found: {len(lines)}\n" + f"You should output {length} lines " + + f"(for the count number {clue[2]}).\n" + + f"Lines found: {len(lines)}\n" f"Your output:\n" f"{reply.strip()}" ) @@ -30,10 +29,14 @@ def check(self, reply: str, clue: Any) -> CheckResult: if name not in line_with_name: return CheckResult.wrong( - "The name was " + clue[0] + "\n" + - "But the 4-th line was:\n" + - "\"" + lines[3] + "\"\n\n" + - "4-th line should contain a name of the user" + "The name was " + + clue[0] + + "\n" + + "But the 4-th line was:\n" + + '"' + + lines[3] + + '"\n\n' + + "4-th line should contain a name of the user" ) line_with_age = lines[6].lower() @@ -41,22 +44,25 @@ def check(self, reply: str, clue: Any) -> CheckResult: if age not in line_with_age: return CheckResult.wrong( - "Can't find a correct age " + - "in the last line of output! " + - "Maybe you calculated the age wrong?\n\n" + - "Your last line: \n" + "\"" + lines[6] + "\"" + "Can't find a correct age " + + "in the last line of output! " + + "Maybe you calculated the age wrong?\n\n" + + "Your last line: \n" + + '"' + + lines[6] + + '"' ) for i in range(clue[2] + 1): - num_line = lines[i + 8].strip().replace(' ', '') - actual_num = f'{i}!' + num_line = lines[i + 8].strip().replace(" ", "") + actual_num = f"{i}!" if num_line != actual_num: return CheckResult.wrong( - f"Expected {i + 8}-th line: \n" + - f"\"{actual_num}\"\n" + - f"Your {i + 8}-th line: \n" + - f"\"{num_line}\"" + f"Expected {i + 8}-th line: \n" + + f'"{actual_num}"\n' + + f"Your {i + 8}-th line: \n" + + f'"{num_line}"' ) return CheckResult.correct() diff --git a/tests/projects/javascript/simple_chatty_bot/stage5/tests.py b/tests/projects/javascript/simple_chatty_bot/stage5/tests.py index a3c1deb4..f20799d8 100644 --- a/tests/projects/javascript/simple_chatty_bot/stage5/tests.py +++ b/tests/projects/javascript/simple_chatty_bot/stage5/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,19 +12,17 @@ class ChattyBotTest(StageTest): def generate(self) -> List[TestCase]: stdin = "Marry\n1\n0\n5\n10" for i in range(10): - stdin += f'\n{i}' - return [ - TestCase(stdin=stdin, attach=("Marry", 40, 10)) - ] + stdin += f"\n{i}" + return [TestCase(stdin=stdin, attach=("Marry", 40, 10))] def check(self, reply: str, clue: Any) -> CheckResult: lines = reply.strip().splitlines() length = 9 + clue[2] + 1 if len(lines) <= length: return CheckResult.wrong( - f"You should output at least {length} lines " + - f"(for the count number {clue[2]}).\n" + - f"Lines found: {len(lines)}" + f"You should output at least {length} lines " + + f"(for the count number {clue[2]}).\n" + + f"Lines found: {len(lines)}" f"Your output:\n" f"{reply.strip()}" ) @@ -33,10 +32,14 @@ def check(self, reply: str, clue: Any) -> CheckResult: if name not in line_with_name: return CheckResult.wrong( - "The name was " + clue[0] + "\n" + - "But the 4-th line was:\n" + - "\"" + lines[3] + "\"\n\n" + - "4-th line should contain a name of the user" + "The name was " + + clue[0] + + "\n" + + "But the 4-th line was:\n" + + '"' + + lines[3] + + '"\n\n' + + "4-th line should contain a name of the user" ) line_with_age = lines[6].lower() @@ -44,30 +47,33 @@ def check(self, reply: str, clue: Any) -> CheckResult: if age not in line_with_age: return CheckResult.wrong( - "Can't find a correct age! " + - "Maybe you calculated the age wrong?\n\n" + - "Your line with age: \n" + "\"" + lines[6] + "\"" + "Can't find a correct age! " + + "Maybe you calculated the age wrong?\n\n" + + "Your line with age: \n" + + '"' + + lines[6] + + '"' ) for i in range(clue[2] + 1): - num_line = lines[i + 8].strip().replace(' ', '') - actual_num = f'{i}!' + num_line = lines[i + 8].strip().replace(" ", "") + actual_num = f"{i}!" if num_line != actual_num: return CheckResult.wrong( - f"Expected {i + 8}-th line: \n" + - f"\"{actual_num}\"\n" + - f"Your {i + 8}-th line: \n" + - f"\"{num_line}\"" + f"Expected {i + 8}-th line: \n" + + f'"{actual_num}"\n' + + f"Your {i + 8}-th line: \n" + + f'"{num_line}"' ) last_line = lines[-1] if "Congratulations, have a nice day!" != last_line: return CheckResult.wrong( - "Your last line should be:\n" + - "\"Congratulations, have a nice day!\"\n" + - "Found:\n" + - f"\"{last_line}\"" + "Your last line should be:\n" + + '"Congratulations, have a nice day!"\n' + + "Found:\n" + + f'"{last_line}"' ) return CheckResult.correct() diff --git a/tests/projects/javascript/zookeeper/stage1/tests.py b/tests/projects/javascript/zookeeper/stage1/tests.py index 35d3ff4a..d999624f 100644 --- a/tests/projects/javascript/zookeeper/stage1/tests.py +++ b/tests/projects/javascript/zookeeper/stage1/tests.py @@ -2,20 +2,23 @@ from hstest.stage_test import StageTest from hstest.test_case import TestCase -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) class Zookeeper(StageTest): def generate(self): - return [TestCase(attach= - "I love animals!\n" - "Let's check on the animals...\n" - "The deer looks fine.\n" - "The bat looks happy.\n" - "The lion looks healthy.")] + return [ + TestCase( + attach="I love animals!\n" + "Let's check on the animals...\n" + "The deer looks fine.\n" + "The bat looks happy.\n" + "The lion looks healthy." + ) + ] def check(self, reply, attach): if attach not in reply.strip(): - return CheckResult.wrong('Your output should be like in the example!') + return CheckResult.wrong("Your output should be like in the example!") return CheckResult.correct() diff --git a/tests/projects/javascript/zookeeper/stage2/tests.py b/tests/projects/javascript/zookeeper/stage2/tests.py index 0308786b..820c2284 100644 --- a/tests/projects/javascript/zookeeper/stage2/tests.py +++ b/tests/projects/javascript/zookeeper/stage2/tests.py @@ -130,5 +130,5 @@ def generate(self): def check(self, reply, attach): if attach.strip() not in reply.strip(): - return CheckResult.wrong('You should output a camel!') + return CheckResult.wrong("You should output a camel!") return CheckResult.correct() diff --git a/tests/projects/javascript/zookeeper/stage3/tests.py b/tests/projects/javascript/zookeeper/stage3/tests.py index 1ec84b5e..affff6ba 100644 --- a/tests/projects/javascript/zookeeper/stage3/tests.py +++ b/tests/projects/javascript/zookeeper/stage3/tests.py @@ -124,12 +124,12 @@ It looks like we will soon have more rabbits!""" animal_index = { - '0': (camel, 'camel'), - '1': (lion, 'lion'), - '2': (deer, 'deer'), - '3': (goose, 'goose'), - '4': (bat, 'bat'), - '5': (rabbit, 'rabbit') + "0": (camel, "camel"), + "1": (lion, "lion"), + "2": (deer, "deer"), + "3": (goose, "goose"), + "4": (bat, "bat"), + "5": (rabbit, "rabbit"), } the_end_message = "---\nYou've reached the end of the program. To check another habitat, please restart the watcher." @@ -137,12 +137,19 @@ class Zookeeper(StageTest): def generate(self): - tests = [TestCase(stdin=index, attach=(index, animal_index[index])) for index in animal_index] + tests = [ + TestCase(stdin=index, attach=(index, animal_index[index])) + for index in animal_index + ] return tests def check(self, reply, attach): if attach[1][0].strip() not in reply.strip(): - return CheckResult.wrong(f'You should output a {attach[1][1]} when the input is the number {attach[0]}') + return CheckResult.wrong( + f"You should output a {attach[1][1]} when the input is the number {attach[0]}" + ) if the_end_message not in reply.strip(): - return CheckResult.wrong('You should output the message about the end of the program!') + return CheckResult.wrong( + "You should output the message about the end of the program!" + ) return CheckResult.correct() diff --git a/tests/projects/javascript/zookeeper/stage4/tests.py b/tests/projects/javascript/zookeeper/stage4/tests.py index 23c9b410..dfbcfd63 100644 --- a/tests/projects/javascript/zookeeper/stage4/tests.py +++ b/tests/projects/javascript/zookeeper/stage4/tests.py @@ -124,44 +124,52 @@ It looks like we will soon have more rabbits!""" animal_index = { - '0': (camel, 'camel'), - '1': (lion, 'lion'), - '2': (deer, 'deer'), - '3': (goose, 'goose'), - '4': (bat, 'bat'), - '5': (rabbit, 'rabbit') + "0": (camel, "camel"), + "1": (lion, "lion"), + "2": (deer, "deer"), + "3": (goose, "goose"), + "4": (bat, "bat"), + "5": (rabbit, "rabbit"), } -the_end_message = 'See you later!' +the_end_message = "See you later!" class Zookeeper(StageTest): def generate(self): tests = [ - TestCase(stdin='1\nexit', attach='1\nexit'), - TestCase(stdin='3\nexit', attach='3\nexit'), - TestCase(stdin='5\nexit', attach='5\nexit'), - TestCase(stdin='0\n2\n4\nexit', attach='0\n2\n4\nexit'), - TestCase(stdin='0\n1\n2\n3\n4\n5\nexit', attach='0\n1\n2\n3\n4\n5\nexit'), + TestCase(stdin="1\nexit", attach="1\nexit"), + TestCase(stdin="3\nexit", attach="3\nexit"), + TestCase(stdin="5\nexit", attach="5\nexit"), + TestCase(stdin="0\n2\n4\nexit", attach="0\n2\n4\nexit"), + TestCase(stdin="0\n1\n2\n3\n4\n5\nexit", attach="0\n1\n2\n3\n4\n5\nexit"), ] return tests def check(self, reply, attach): indexes = list(map(str, range(6))) - included_animals = attach.replace('\nexit', '').split('\n') + included_animals = attach.replace("\nexit", "").split("\n") excluded_animals = [index for index in indexes if index not in included_animals] for index in included_animals: if animal_index[index][0].strip() not in reply: - return CheckResult.wrong("The " + animal_index[index][1] + " wasn't printed but was expected") + return CheckResult.wrong( + "The " + animal_index[index][1] + " wasn't printed but was expected" + ) for index in excluded_animals: if animal_index[index][0].strip() in reply: - return CheckResult.wrong("The " + animal_index[index][1] + " was printed but wasn't expected") + return CheckResult.wrong( + "The " + animal_index[index][1] + " was printed but wasn't expected" + ) if the_end_message not in reply: - return CheckResult.wrong("You should print '{}' at the end of the program".format(the_end_message)) + return CheckResult.wrong( + "You should print '{}' at the end of the program".format( + the_end_message + ) + ) return CheckResult.correct() diff --git a/tests/projects/python/coffee_machine/stage1/machine/coffee_machine.py b/tests/projects/python/coffee_machine/stage1/machine/coffee_machine.py index 9217884a..6189bf13 100644 --- a/tests/projects/python/coffee_machine/stage1/machine/coffee_machine.py +++ b/tests/projects/python/coffee_machine/stage1/machine/coffee_machine.py @@ -1,8 +1,10 @@ # Write your code here -print("""Starting to make a coffee +print( + """Starting to make a coffee Grinding coffee beans Boiling water Mixing boiled water with crushed coffee beans Pouring coffee into the cup Pouring some milk into the cup -Coffee is ready!""") +Coffee is ready!""" +) diff --git a/tests/projects/python/coffee_machine/stage1/tests.py b/tests/projects/python/coffee_machine/stage1/tests.py index 947ca431..f236699c 100644 --- a/tests/projects/python/coffee_machine/stage1/tests.py +++ b/tests/projects/python/coffee_machine/stage1/tests.py @@ -1,10 +1,10 @@ from typing import List +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -20,9 +20,10 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/python/coffee_machine/stage2/tests.py b/tests/projects/python/coffee_machine/stage2/tests.py index 33564d63..11314142 100644 --- a/tests/projects/python/coffee_machine/stage2/tests.py +++ b/tests/projects/python/coffee_machine/stage2/tests.py @@ -1,21 +1,17 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( - [ - ('25', '25'), - ('125', '125'), - ('1', '1'), - ('123', '123') - ] + [("25", "25"), ("125", "125"), ("1", "1"), ("123", "123")] ) def check(self, reply: str, clue: Any) -> CheckResult: @@ -24,45 +20,46 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(lines) < 3: return CheckResult.wrong( - 'Output contains less than 3 lines, ' - 'but should output at least 3 lines') + "Output contains less than 3 lines, " + "but should output at least 3 lines" + ) last_3_lines = reply.splitlines()[-3:] cups = int(clue) water = milk = beans = False for line in last_3_lines: line = line.lower() - if 'milk' in line: + if "milk" in line: milk = str(cups * 50) in line if not milk: return CheckResult.wrong( - f"For the input {clue} your program output:\n\"" + - f"{line}\"\nbut the amount of milk should be {cups * 50}" + f'For the input {clue} your program output:\n"' + + f'{line}"\nbut the amount of milk should be {cups * 50}' ) - elif 'water' in line: + elif "water" in line: water = str(cups * 200) in line if not water: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of water should be {cups * 200}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of water should be {cups * 200}" ) - elif 'beans' in line: + elif "beans" in line: beans = str(cups * 15) in line if not beans: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of beans should be {cups * 15}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of beans should be {cups * 15}" ) else: return CheckResult.wrong( - "One of the last 3 lines " + - "doesn't contain \"milk\", \"water\" or \"beans\"" + "One of the last 3 lines " + + 'doesn\'t contain "milk", "water" or "beans"' ) if not water: diff --git a/tests/projects/python/coffee_machine/stage3/machine/coffee_machine.py b/tests/projects/python/coffee_machine/stage3/machine/coffee_machine.py index 1d73eddd..2319d340 100644 --- a/tests/projects/python/coffee_machine/stage3/machine/coffee_machine.py +++ b/tests/projects/python/coffee_machine/stage3/machine/coffee_machine.py @@ -1,7 +1,9 @@ # Write your code here -water_amount = int(input('Write how many ml of water the coffee machine has:')) -milk_amount = int(input('Write how many ml of milk the coffee machine has:')) -coffee_amount = int(input('Write how many grams of coffee beans the coffee machine has:')) +water_amount = int(input("Write how many ml of water the coffee machine has:")) +milk_amount = int(input("Write how many ml of milk the coffee machine has:")) +coffee_amount = int( + input("Write how many grams of coffee beans the coffee machine has:") +) N = int(water_amount / 200) if N > milk_amount / 50: N = int(milk_amount / 50) @@ -11,19 +13,19 @@ if number_cups == N: print("Yes, I can make that amount of coffee") elif N > number_cups: - print("Yes, I can make that amount of coffee (and even ", N-1," more than that)") + print("Yes, I can make that amount of coffee (and even ", N - 1, " more than that)") else: - print("No, I can make only ", N," cups of coffee") -#print("""Starting to make a coffee -#Grinding coffee beans -#Boiling water -#Mixing boiled water with crushed coffee beans -#Pouring coffee into the cup -#Pouring some milk into the cup -#Coffee is ready!""") + print("No, I can make only ", N, " cups of coffee") +# print("""Starting to make a coffee +# Grinding coffee beans +# Boiling water +# Mixing boiled water with crushed coffee beans +# Pouring coffee into the cup +# Pouring some milk into the cup +# Coffee is ready!""") # # -#print("For ", number_cups, " cups of coffee you will need:") -#print(200 * number_cups, " ml of water") -#print(50 * number_cups, " ml of milk") -#print(15 * number_cups, " g of coffee beans") \ No newline at end of file +# print("For ", number_cups, " cups of coffee you will need:") +# print(200 * number_cups, " ml of water") +# print(50 * number_cups, " ml of milk") +# print(15 * number_cups, " g of coffee beans") diff --git a/tests/projects/python/coffee_machine/stage3/tests.py b/tests/projects/python/coffee_machine/stage3/tests.py index 9dd33dd0..04a5a4a8 100644 --- a/tests/projects/python/coffee_machine/stage3/tests.py +++ b/tests/projects/python/coffee_machine/stage3/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,28 +12,27 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( [ - ('300\n65\n111\n1\n', (True, 0, True)), - ('600\n153\n100\n1', (True, 2, True)), - ('1400\n150\n100\n1', (True, 2, True)), - ('1400\n1500\n45\n1', (True, 2, True)), - ('599\n250\n200\n10', (False, 2, True)), - ('34564\n43423\n23234\n1', (True, 171, True)), - ('345640\n434230\n23234\n1', (True, 1547, True)), - ('345640\n43423\n23234\n19246', (False, 868, True)), - - ('399\n112\n111\n1', (True, 0, False)), - ('2400\n249\n100\n1', (True, 3, False)), - ('1400\n1500\n44\n1', (True, 1, False)), - ('500\n250\n200\n10', (False, 2, False)), - ('600\n250\n200\n10', (False, 3, False)), - ('345640\n43423\n23234\n1', (True, 867, False)), - ('345640\n434230\n23234\n19246', (False, 1548, False)), - ('34564\n43423\n23234\n19246', (False, 172, False)), + ("300\n65\n111\n1\n", (True, 0, True)), + ("600\n153\n100\n1", (True, 2, True)), + ("1400\n150\n100\n1", (True, 2, True)), + ("1400\n1500\n45\n1", (True, 2, True)), + ("599\n250\n200\n10", (False, 2, True)), + ("34564\n43423\n23234\n1", (True, 171, True)), + ("345640\n434230\n23234\n1", (True, 1547, True)), + ("345640\n43423\n23234\n19246", (False, 868, True)), + ("399\n112\n111\n1", (True, 0, False)), + ("2400\n249\n100\n1", (True, 3, False)), + ("1400\n1500\n44\n1", (True, 1, False)), + ("500\n250\n200\n10", (False, 2, False)), + ("600\n250\n200\n10", (False, 3, False)), + ("345640\n43423\n23234\n1", (True, 867, False)), + ("345640\n434230\n23234\n19246", (False, 1548, False)), + ("34564\n43423\n23234\n19246", (False, 172, False)), ] ) def check(self, reply: str, clue: Any) -> CheckResult: - user_output = reply.split(':')[-1].strip() + user_output = reply.split(":")[-1].strip() lowered_output = user_output.lower() print("----") print(lowered_output) @@ -40,77 +40,70 @@ def check(self, reply: str, clue: Any) -> CheckResult: ans, amount, show_tests = clue if ans: if amount > 0: - is_correct = f'{amount}' in lowered_output and 'yes' in lowered_output + is_correct = f"{amount}" in lowered_output and "yes" in lowered_output if is_correct: - if f'{amount}.' in lowered_output: + if f"{amount}." in lowered_output: return CheckResult.wrong( "There is a dot after an amount of cups. " "There should be no dot.\n" - "Your output:\n" + - user_output + "Your output:\n" + user_output ) return CheckResult.correct() else: right_output = ( - "Yes, I can make that amount of coffee" + - f" (and even {amount} more than that)" + "Yes, I can make that amount of coffee" + + f" (and even {amount} more than that)" ) if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') - if 'yes, i can make that amount of coffee' == lowered_output: + return CheckResult.wrong("") + if "yes, i can make that amount of coffee" == lowered_output: return CheckResult.correct() else: - right_output = ( - "Yes, I can make that amount of coffee" - ) + right_output = "Yes, I can make that amount of coffee" if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') + return CheckResult.wrong("") else: - cond1 = 'no' in lowered_output + cond1 = "no" in lowered_output cond2 = str(amount) in lowered_output if cond1 and cond2: - if f'{amount}.' in lowered_output: + if f"{amount}." in lowered_output: return CheckResult.wrong( "There is a dot after an amount of cups. " "There should be no dot.\n" - "Your output:\n" + - user_output + "Your output:\n" + user_output ) return CheckResult.correct() else: - right_output = ( - "No, I can make only " + - f"{amount} cup(s) of coffee" - ) + right_output = "No, I can make only " + f"{amount} cup(s) of coffee" if show_tests: return CheckResult.wrong( - "Your output:\n" + - user_output + - "\nRight output:\n" + - right_output + "Your output:\n" + + user_output + + "\nRight output:\n" + + right_output ) else: - return CheckResult.wrong('') + return CheckResult.wrong("") diff --git a/tests/projects/python/coffee_machine/stage4/machine/coffee_machine.py b/tests/projects/python/coffee_machine/stage4/machine/coffee_machine.py index d020838a..683089c7 100644 --- a/tests/projects/python/coffee_machine/stage4/machine/coffee_machine.py +++ b/tests/projects/python/coffee_machine/stage4/machine/coffee_machine.py @@ -4,20 +4,26 @@ cups = 9 money = 550 + def machine_status(): - print(f'''The coffee machine has: + print( + f"""The coffee machine has: {water} of water {milk} of milk {beans} of coffee beans {cups} of disposable cups - {money} of money''') + {money} of money""" + ) + machine_status() action = input("Write action (buy, fill, take):\n") -if action == 'buy': - typ = int(input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino:\n")) +if action == "buy": + typ = int( + input("What do you want to buy? 1 - espresso, 2 - latte, 3 - cappuccino:\n") + ) if typ == 1: water -= 250 beans -= 16 @@ -35,12 +41,12 @@ def machine_status(): beans -= 12 money += 6 cups -= 1 -elif action == 'fill': +elif action == "fill": water += int(input("Write how many ml of water do you want to add:\n")) milk += int(input("Write how many ml of milk do you want to add:\n")) beans += int(input("Write how many grams of coffee beans do you want to add:\n")) cups += int(input("Write how many disposable cups of coffee do you want to add:\n")) -elif action == 'take': +elif action == "take": print(f"I gave you ${money}") money = 0 @@ -58,4 +64,4 @@ def machine_status(): elif cups_max > cups: print(f"Yes, I can make that amount of coffee (and even {cups_max - cups} more than that)") else: - print(f"No, I can make only {cups_max} cups of coffee") """ \ No newline at end of file + print(f"No, I can make only {cups_max} cups of coffee") """ diff --git a/tests/projects/python/coffee_machine/stage4/tests.py b/tests/projects/python/coffee_machine/stage4/tests.py index 5b901da2..3dbf8d12 100644 --- a/tests/projects/python/coffee_machine/stage4/tests.py +++ b/tests/projects/python/coffee_machine/stage4/tests.py @@ -1,9 +1,10 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -11,17 +12,17 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( [ - ('take\n',) * 2, - ('buy\n1\n',) * 2, - ('buy\n2\n',) * 2, - ('buy\n3\n',) * 2, - ('fill\n2001\n510\n101\n21\n',) * 2, + ("take\n",) * 2, + ("buy\n1\n",) * 2, + ("buy\n2\n",) * 2, + ("buy\n3\n",) * 2, + ("fill\n2001\n510\n101\n21\n",) * 2, ] ) def check(self, reply: str, clue: Any) -> CheckResult: if len(reply.splitlines()) <= 1: - return CheckResult.wrong('Too few output lines') + return CheckResult.wrong("Too few output lines") action, *rest = clue.split() @@ -35,49 +36,44 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(line.split()) == 0: continue first_word = line.split()[0] - first_word = first_word.replace('$', '') + first_word = first_word.replace("$", "") if not first_word.isdigit(): continue amount = int(first_word) - if 'milk' in line: - milk += amount, - elif 'water' in line: - water += amount, - elif 'beans' in line: - beans += amount, - elif 'cups' in line: - cups += amount, - elif 'money' in line: - money += amount, + if "milk" in line: + milk += (amount,) + elif "water" in line: + water += (amount,) + elif "beans" in line: + beans += (amount,) + elif "cups" in line: + cups += (amount,) + elif "money" in line: + money += (amount,) if len(milk) != 2: return CheckResult.wrong( - "There should be two lines with \"milk\", " + - f"found: {len(milk)}" + 'There should be two lines with "milk", ' + f"found: {len(milk)}" ) if len(water) != 2: return CheckResult.wrong( - "There should be two lines with \"water\", " + - f"found: {len(water)}" + 'There should be two lines with "water", ' + f"found: {len(water)}" ) if len(beans) != 2: return CheckResult.wrong( - "There should be two lines with \"beans\", " + - f"found: {len(beans)}" + 'There should be two lines with "beans", ' + f"found: {len(beans)}" ) if len(cups) != 2: return CheckResult.wrong( - "There should be two lines with \"cups\", " + - f"found: {len(cups)}" + 'There should be two lines with "cups", ' + f"found: {len(cups)}" ) if len(money) != 2: return CheckResult.wrong( - "There should be two lines with \"money\", " + - f"found: {len(money)}" + 'There should be two lines with "money", ' + f"found: {len(money)}" ) milk = milk[0], milk[-1] @@ -86,187 +82,187 @@ def check(self, reply: str, clue: Any) -> CheckResult: cups = cups[0], cups[-1] money = money[0], money[-1] - if water[0] != 400 or milk[0] != 540 or beans[0] != 120 or cups[0] != 9 or money[0] != 550: + if ( + water[0] != 400 + or milk[0] != 540 + or beans[0] != 120 + or cups[0] != 9 + or money[0] != 550 + ): return CheckResult.wrong( - "Initial setup is wrong: " + - "coffee machine should be filled like " + - "stated in the description" + "Initial setup is wrong: " + + "coffee machine should be filled like " + + "stated in the description" ) diff = lambda item: item[1] - item[0] - if action == 'take': + if action == "take": if diff(milk) != 0: return CheckResult.wrong( - "After \"take\" action milk " + - "amount shouldn't be changed" + 'After "take" action milk ' + "amount shouldn't be changed" ) if diff(water) != 0: return CheckResult.wrong( - "After \"take\" action water " + - "amount shouldn't be changed" + 'After "take" action water ' + "amount shouldn't be changed" ) if diff(beans) != 0: return CheckResult.wrong( - "After \"take\" action beans " + - "amount shouldn't be changed" + 'After "take" action beans ' + "amount shouldn't be changed" ) if diff(cups) != 0: return CheckResult.wrong( - "After \"take\" action cups " + - "amount shouldn't be changed" + 'After "take" action cups ' + "amount shouldn't be changed" ) if money[1] != 0: return CheckResult.wrong( - "After \"take\" action money " + - "amount should be zero" + 'After "take" action money ' + "amount should be zero" ) return CheckResult.correct() - elif action == 'buy': + elif action == "buy": option = rest[0] - if option == '1': + if option == "1": if diff(water) != -250: return CheckResult.wrong( - "After buying the first option " + - "water amount should be lowered by 250" + "After buying the first option " + + "water amount should be lowered by 250" ) if diff(milk) != 0: return CheckResult.wrong( - "After buying the first option " + - "milk amount should not be changed" + "After buying the first option " + + "milk amount should not be changed" ) if diff(beans) != -16: return CheckResult.wrong( - "After buying the first option " + - "beans amount should be lowered by 16" + "After buying the first option " + + "beans amount should be lowered by 16" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the first option " + - "cups amount should be lowered by 1" + "After buying the first option " + + "cups amount should be lowered by 1" ) if diff(money) != 4: return CheckResult.wrong( - "After buying the first option " + - "money amount should be increased by 4" + "After buying the first option " + + "money amount should be increased by 4" ) return CheckResult.correct() - elif option == '2': + elif option == "2": if diff(water) != -350: return CheckResult.wrong( - "After buying the second option " + - "water amount should be lowered by 350" + "After buying the second option " + + "water amount should be lowered by 350" ) if diff(milk) != -75: return CheckResult.wrong( - "After buying the second option " + - "milk amount should be lowered by 75" + "After buying the second option " + + "milk amount should be lowered by 75" ) if diff(beans) != -20: return CheckResult.wrong( - "After buying the second option " + - "beans amount should be lowered by 20" + "After buying the second option " + + "beans amount should be lowered by 20" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the second option " + - "cups amount should be lowered by 1" + "After buying the second option " + + "cups amount should be lowered by 1" ) if diff(money) != 7: return CheckResult.wrong( - "After buying the second option " + - "money amount should be increased by 7" + "After buying the second option " + + "money amount should be increased by 7" ) return CheckResult.correct() - elif option == '3': + elif option == "3": if diff(water) != -200: return CheckResult.wrong( - "After buying the third option " + - "water amount should be lowered by 200" + "After buying the third option " + + "water amount should be lowered by 200" ) if diff(milk) != -100: return CheckResult.wrong( - "After buying the third option " + - "milk amount should be lowered by 100" + "After buying the third option " + + "milk amount should be lowered by 100" ) if diff(beans) != -12: return CheckResult.wrong( - "After buying the third option " + - "beans amount should be lowered by 12" + "After buying the third option " + + "beans amount should be lowered by 12" ) if diff(cups) != -1: return CheckResult.wrong( - "After buying the third option " + - "cups amount should be lowered by 1" + "After buying the third option " + + "cups amount should be lowered by 1" ) if diff(money) != 6: return CheckResult.wrong( - "After buying the third option " + - "money amount should be increased by 6" + "After buying the third option " + + "money amount should be increased by 6" ) return CheckResult.correct() - elif action == 'fill': + elif action == "fill": water_, milk_, beans_, cups_ = map(int, rest) if diff(money) != 0: return CheckResult.wrong( - "After \"fill\" action " + - "money amount should not be changed" + 'After "fill" action ' + "money amount should not be changed" ) if diff(water) != water_: return CheckResult.wrong( - "After \"fill\" action " + - f"water amount expected to be increased by {water_}" + - f" but was increased by {diff(water)}" + 'After "fill" action ' + + f"water amount expected to be increased by {water_}" + + f" but was increased by {diff(water)}" ) if diff(milk) != milk_: return CheckResult.wrong( - "After \"fill\" action " + - f"milk amount expected to be increased by {milk_}" + - f" but was increased by {diff(milk)}" + 'After "fill" action ' + + f"milk amount expected to be increased by {milk_}" + + f" but was increased by {diff(milk)}" ) if diff(beans) != beans_: return CheckResult.wrong( - "After \"fill\" action " + - f"beans amount expected to be increased by {beans_}" + - f" but was increased by {diff(beans)}" + 'After "fill" action ' + + f"beans amount expected to be increased by {beans_}" + + f" but was increased by {diff(beans)}" ) if diff(cups) != cups_: return CheckResult.wrong( - "After \"fill\" action " + - f"cups amount expected to be increased by {cups_}" + - f" but was increased by {diff(cups)}" + 'After "fill" action ' + + f"cups amount expected to be increased by {cups_}" + + f" but was increased by {diff(cups)}" ) return CheckResult.correct() diff --git a/tests/projects/python/coffee_machine/stage5/machine/coffee_machine.py b/tests/projects/python/coffee_machine/stage5/machine/coffee_machine.py index 50975b9d..cc4c2d44 100644 --- a/tests/projects/python/coffee_machine/stage5/machine/coffee_machine.py +++ b/tests/projects/python/coffee_machine/stage5/machine/coffee_machine.py @@ -33,8 +33,10 @@ def action_handle(user_action_def): def buy_coffee(): - print("What do you want to buy? " - + "1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:") + print( + "What do you want to buy? " + + "1 - espresso, 2 - latte, 3 - cappuccino, back - to main menu:" + ) user_choice = input() if user_choice == "back": return False @@ -76,11 +78,11 @@ def check_resources(user_choice): def change_machine_state(machine, coffee_cost): - for i in range(len(machine)-1): + for i in range(len(machine) - 1): machine[i] -= coffee_cost[i] # print(machine[i]) # add money - machine[len(machine)-1] += coffee_cost[len(machine)-1] + machine[len(machine) - 1] += coffee_cost[len(machine) - 1] def fill_machine(machine): diff --git a/tests/projects/python/coffee_machine/stage5/tests.py b/tests/projects/python/coffee_machine/stage5/tests.py index 37c309a9..4012e103 100644 --- a/tests/projects/python/coffee_machine/stage5/tests.py +++ b/tests/projects/python/coffee_machine/stage5/tests.py @@ -1,12 +1,13 @@ +from typing import List + +from hstest.check_result import CheckResult from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) -test1_input = '''remaining +test1_input = """remaining buy 2 buy @@ -21,9 +22,9 @@ take remaining exit -''' +""" -test2_input = '''remaining +test2_input = """remaining fill 3000 3000 @@ -31,41 +32,41 @@ 3000 remaining exit -''' +""" -test3_input = '''remaining +test3_input = """remaining buy 1 remaining exit -''' +""" -test4_input = '''remaining +test4_input = """remaining buy 2 remaining exit -''' +""" -test5_input = '''remaining +test5_input = """remaining buy 3 remaining exit -''' +""" -test6_input = '''remaining +test6_input = """remaining take remaining exit -''' +""" -test7_input = '''remaining +test7_input = """remaining buy back remaining exit -''' +""" class CoffeeMachineTest(StageTest): @@ -81,22 +82,13 @@ def generate(self) -> List[TestCase]: 7 - 9, 0 - 550, "This test is exactly like in the example " - "- try to run it by yourself" - ) + "- try to run it by yourself", + ), ), - ( test2_input, - ( - 3000, - 3000, - 3000, - 3000, - 0, - "This test checks \"fill\" action" - ) + (3000, 3000, 3000, 3000, 0, 'This test checks "fill" action'), ), - ( test3_input, ( @@ -105,11 +97,10 @@ def generate(self) -> List[TestCase]: -16, -1, 4, - "This test checks \"buy\" " + - "action with the first variant of coffee" - ) + 'This test checks "buy" ' + + "action with the first variant of coffee", + ), ), - ( test4_input, ( @@ -118,11 +109,10 @@ def generate(self) -> List[TestCase]: -20, -1, 7, - "This test checks \"buy\" " + - "action with the second variant of coffee" - ) + 'This test checks "buy" ' + + "action with the second variant of coffee", + ), ), - ( test5_input, ( @@ -131,22 +121,11 @@ def generate(self) -> List[TestCase]: -12, -1, 6, - "This test checks \"buy\" " + - "action with the third variant of coffee" - ) + 'This test checks "buy" ' + + "action with the third variant of coffee", + ), ), - ( - test6_input, - ( - 0, - 0, - 0, - 0, - -550, - "This test checks \"take\" action" - ) - ), - + (test6_input, (0, 0, 0, 0, -550, 'This test checks "take" action')), ( test7_input, ( @@ -155,16 +134,15 @@ def generate(self) -> List[TestCase]: 0, 0, 0, - "This test checks \"back\" " + - "action right after \"buy\" action" - ) + 'This test checks "back" ' + 'action right after "buy" action', + ), ), ] ) def check(self, reply: str, clue: Any) -> CheckResult: if len(reply.splitlines()) <= 1: - return CheckResult.wrong('Too few lines in output') + return CheckResult.wrong("Too few lines in output") water_, milk_, beans_, cups_, money_, feedback = clue @@ -175,52 +153,47 @@ def check(self, reply: str, clue: Any) -> CheckResult: money = [] for line in reply.splitlines(): - line = line.replace('$', '').strip() + line = line.replace("$", "").strip() if len(line.split()) == 0: continue first_word = line.split()[0] if not first_word.isdigit(): continue amount = int(first_word) - if 'milk' in line: - milk += amount, - elif 'water' in line: - water += amount, - elif 'beans' in line: - beans += amount, - elif 'cups' in line: - cups += amount, - elif 'money' in line or 'cash' in line: - money += amount, + if "milk" in line: + milk += (amount,) + elif "water" in line: + water += (amount,) + elif "beans" in line: + beans += (amount,) + elif "cups" in line: + cups += (amount,) + elif "money" in line or "cash" in line: + money += (amount,) if len(milk) != 2: return CheckResult.wrong( - "There should be two lines with \"milk\", " + - f"found: {len(milk)}" + 'There should be two lines with "milk", ' + f"found: {len(milk)}" ) if len(water) != 2: return CheckResult.wrong( - "There should be two lines with \"water\", " + - f"found: {len(water)}" + 'There should be two lines with "water", ' + f"found: {len(water)}" ) if len(beans) != 2: return CheckResult.wrong( - "There should be two lines with \"beans\", " + - f"found: {len(beans)}" + 'There should be two lines with "beans", ' + f"found: {len(beans)}" ) if len(cups) != 2: return CheckResult.wrong( - "There should be two lines with \"cups\", " + - f"found: {len(cups)}" + 'There should be two lines with "cups", ' + f"found: {len(cups)}" ) if len(money) != 2: return CheckResult.wrong( - "There should be two lines with \"money\", " + - f"found: {len(money)}" + 'There should be two lines with "money", ' + f"found: {len(money)}" ) milk = milk[0], milk[-1] @@ -232,10 +205,10 @@ def check(self, reply: str, clue: Any) -> CheckResult: diff = lambda item: item[1] - item[0] is_correct = ( - diff(water) == water_ and - diff(milk) == milk_ and - diff(beans) == beans_ and - diff(cups) == cups_ and - diff(money) == money_ + diff(water) == water_ + and diff(milk) == milk_ + and diff(beans) == beans_ + and diff(cups) == cups_ + and diff(money) == money_ ) return CheckResult(is_correct, feedback) diff --git a/tests/projects/shell/coffee_machine/stage1/tests.py b/tests/projects/shell/coffee_machine/stage1/tests.py index 86fb4c6c..caee83fa 100644 --- a/tests/projects/shell/coffee_machine/stage1/tests.py +++ b/tests/projects/shell/coffee_machine/stage1/tests.py @@ -1,10 +1,11 @@ +from typing import List + +from hstest.check_result import CheckResult +from hstest.common.os_utils import is_windows from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.common.os_utils import is_windows -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -21,9 +22,10 @@ @unittest.skipIf(is_windows(), reason="Windows doesn't support bash projects") class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/shell/coffee_machine/stage1_ex/tests.py b/tests/projects/shell/coffee_machine/stage1_ex/tests.py index 34c05c0a..be68b620 100644 --- a/tests/projects/shell/coffee_machine/stage1_ex/tests.py +++ b/tests/projects/shell/coffee_machine/stage1_ex/tests.py @@ -1,11 +1,12 @@ +from typing import List + +from hstest.check_result import CheckResult +from hstest.common.os_utils import is_windows from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.common.os_utils import is_windows -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -28,9 +29,10 @@ class CoffeeMachineTest(UserErrorTest): """ def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/shell/coffee_machine/stage1_wa/tests.py b/tests/projects/shell/coffee_machine/stage1_wa/tests.py index bb7a97c3..3d31c2e0 100644 --- a/tests/projects/shell/coffee_machine/stage1_wa/tests.py +++ b/tests/projects/shell/coffee_machine/stage1_wa/tests.py @@ -1,11 +1,12 @@ +from typing import List + +from hstest.check_result import CheckResult +from hstest.common.os_utils import is_windows from hstest.stage_test import * from hstest.test_case import TestCase from hstest.testing.unittest.user_error_test import UserErrorTest -from hstest.common.os_utils import is_windows -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) OUTPUT = """ @@ -34,9 +35,10 @@ class CoffeeMachineTest(UserErrorTest): """ def generate(self) -> List[TestCase]: - return TestCase.from_stepik([('', OUTPUT)]) + return TestCase.from_stepik([("", OUTPUT)]) def check(self, reply: str, clue: Any) -> CheckResult: return CheckResult( reply.strip() == clue.strip(), - 'You should make coffee exactly like in the example') + "You should make coffee exactly like in the example", + ) diff --git a/tests/projects/shell/coffee_machine/stage2/tests.py b/tests/projects/shell/coffee_machine/stage2/tests.py index 911b5a69..6bae1db0 100644 --- a/tests/projects/shell/coffee_machine/stage2/tests.py +++ b/tests/projects/shell/coffee_machine/stage2/tests.py @@ -1,10 +1,11 @@ +from typing import List + +from hstest.check_result import CheckResult +from hstest.common.os_utils import is_windows from hstest.stage_test import * from hstest.test_case import TestCase -from hstest.common.os_utils import is_windows -from hstest.check_result import CheckResult -from typing import List -CheckResult.correct = lambda: CheckResult(True, '') +CheckResult.correct = lambda: CheckResult(True, "") CheckResult.wrong = lambda feedback: CheckResult(False, feedback) @@ -12,12 +13,7 @@ class CoffeeMachineTest(StageTest): def generate(self) -> List[TestCase]: return TestCase.from_stepik( - [ - ('25', '25'), - ('125', '125'), - ('1', '1'), - ('123', '123') - ] + [("25", "25"), ("125", "125"), ("1", "1"), ("123", "123")] ) def check(self, reply: str, clue: Any) -> CheckResult: @@ -26,45 +22,46 @@ def check(self, reply: str, clue: Any) -> CheckResult: if len(lines) < 3: return CheckResult.wrong( - 'Output contains less than 3 lines, ' - 'but should output at least 3 lines') + "Output contains less than 3 lines, " + "but should output at least 3 lines" + ) last_3_lines = reply.splitlines()[-3:] cups = int(clue) water = milk = beans = False for line in last_3_lines: line = line.lower() - if 'milk' in line: + if "milk" in line: milk = str(cups * 50) in line if not milk: return CheckResult.wrong( - f"For the input {clue} your program output:\n\"" + - f"{line}\"\nbut the amount of milk should be {cups * 50}" + f'For the input {clue} your program output:\n"' + + f'{line}"\nbut the amount of milk should be {cups * 50}' ) - elif 'water' in line: + elif "water" in line: water = str(cups * 200) in line if not water: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of water should be {cups * 200}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of water should be {cups * 200}" ) - elif 'beans' in line: + elif "beans" in line: beans = str(cups * 15) in line if not beans: return CheckResult.wrong( - f"For the input {clue} your program output:\n" + - f"{line}\nbut the amount of beans should be {cups * 15}" + f"For the input {clue} your program output:\n" + + f"{line}\nbut the amount of beans should be {cups * 15}" ) else: return CheckResult.wrong( - "One of the last 3 lines " + - "doesn't contain \"milk\", \"water\" or \"beans\"" + "One of the last 3 lines " + + 'doesn\'t contain "milk", "water" or "beans"' ) if not water: diff --git a/tests/sql/test_db_connection/sqlite/test.py b/tests/sql/test_db_connection/sqlite/test.py index 6002bd75..d50ac7d6 100644 --- a/tests/sql/test_db_connection/sqlite/test.py +++ b/tests/sql/test_db_connection/sqlite/test.py @@ -1,12 +1,12 @@ from sqlite3 import Connection -from hstest import correct, dynamic_test, SQLTest, wrong +from hstest import SQLTest, correct, dynamic_test, wrong class TestSQLProject(SQLTest): @dynamic_test def test_queries(self): if type(self.db) is not Connection: - return wrong('SQLite should be used by default') + return wrong("SQLite should be used by default") return correct() diff --git a/tests/sql/test_parsing_sql_files/parsing1/test.py b/tests/sql/test_parsing_sql_files/parsing1/test.py index dbcec6f5..f6f201ec 100644 --- a/tests/sql/test_parsing_sql_files/parsing1/test.py +++ b/tests/sql/test_parsing_sql_files/parsing1/test.py @@ -1,25 +1,24 @@ -from hstest import correct, dynamic_test, SQLTest, wrong +from hstest import SQLTest, correct, dynamic_test, wrong class TestSQLProject(SQLTest): - queries = { - 'create_table': None, - 'test': None - } + queries = {"create_table": None, "test": None} @dynamic_test def test_queries(self): expected_queries = { - 'create_table': "CREATE TABLE STUDENT( ID INT PRIMARY KEY NOT NULL, " - "NAME CHAR(20) NOT NULL," - " ROLL CHAR(20), ADDRESS CHAR(50), CLASS CHAR(20) )", - 'test': "UPDATE Customers SET ContactName = 'Alfred Schmidt', " - "City= 'Frankfurt' WHERE CustomerID = 1" + "create_table": "CREATE TABLE STUDENT( ID INT PRIMARY KEY NOT NULL, " + "NAME CHAR(20) NOT NULL," + " ROLL CHAR(20), ADDRESS CHAR(50), CLASS CHAR(20) )", + "test": "UPDATE Customers SET ContactName = 'Alfred Schmidt', " + "City= 'Frankfurt' WHERE CustomerID = 1", } for query in self.queries: if self.queries[query] != expected_queries[query]: - return wrong(f"'{query}' is wrong! \n Expected:\n {expected_queries[query]}\n" - f"Found:\n{self.queries[query]}") + return wrong( + f"'{query}' is wrong! \n Expected:\n {expected_queries[query]}\n" + f"Found:\n{self.queries[query]}" + ) return correct() diff --git a/tests/sql/test_queries/execute/test_execute_query_name_with_wrong_query/test.py b/tests/sql/test_queries/execute/test_execute_query_name_with_wrong_query/test.py index 9b5a41f6..00429a04 100644 --- a/tests/sql/test_queries/execute/test_execute_query_name_with_wrong_query/test.py +++ b/tests/sql/test_queries/execute/test_execute_query_name_with_wrong_query/test.py @@ -1,19 +1,18 @@ import unittest -from hstest import correct, dynamic_test, SQLTest +from hstest import SQLTest, correct, dynamic_test -@unittest.skip("This class should inherit UserErrorTest, but can't since it " - "inherits StageTest, not SQLTest") +@unittest.skip( + "This class should inherit UserErrorTest, but can't since it " + "inherits StageTest, not SQLTest" +) class TestSQLProject(SQLTest): - queries = { - 'create_table': None, - 'insert_data': None - } + queries = {"create_table": None, "insert_data": None} @dynamic_test def test_create_table(self): - self.execute('create_table') + self.execute("create_table") return correct() @@ -22,9 +21,9 @@ class Test(unittest.TestCase): def test(self): status, feedback = TestSQLProject().run_tests() self.assertEqual(status, -1) - self.assertIn('Wrong answer in test #1', feedback) + self.assertIn("Wrong answer in test #1", feedback) self.assertIn('near "CRE": syntax error', feedback) -if __name__ == '__main__': +if __name__ == "__main__": Test().test() diff --git a/tests/sql/test_queries/execute/test_execute_with_plain_query/test.py b/tests/sql/test_queries/execute/test_execute_with_plain_query/test.py index 9e5ebb56..80e8237b 100644 --- a/tests/sql/test_queries/execute/test_execute_with_plain_query/test.py +++ b/tests/sql/test_queries/execute/test_execute_with_plain_query/test.py @@ -1,24 +1,26 @@ -from hstest import correct, dynamic_test, SQLTest, wrong +from hstest import SQLTest, correct, dynamic_test, wrong class TestSQLProject(SQLTest): - queries = { - 'create_table': None - } + queries = {"create_table": None} @dynamic_test def test_queries(self): - self.execute("""CREATE TABLE contacts ( + self.execute( + """CREATE TABLE contacts ( contact_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, email TEXT NOT NULL UNIQUE, phone TEXT NOT NULL UNIQUE - );""") + );""" + ) - result = self.db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;") + result = self.db.execute( + "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;" + ) - if 'contacts' not in result.fetchall()[0]: + if "contacts" not in result.fetchall()[0]: return wrong("Can't find 'contacts' table in the database") return correct() diff --git a/tests/sql/test_queries/execute/test_execute_with_query_name/test.py b/tests/sql/test_queries/execute/test_execute_with_query_name/test.py index 5cd6c223..492449b2 100644 --- a/tests/sql/test_queries/execute/test_execute_with_query_name/test.py +++ b/tests/sql/test_queries/execute/test_execute_with_query_name/test.py @@ -1,18 +1,18 @@ -from hstest import correct, dynamic_test, SQLTest, wrong +from hstest import SQLTest, correct, dynamic_test, wrong class TestSQLProject(SQLTest): - queries = { - 'create_table': None - } + queries = {"create_table": None} @dynamic_test def test_queries(self): - self.execute('create_table') + self.execute("create_table") - result = self.db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;") + result = self.db.execute( + "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;" + ) - if 'contacts' not in result.fetchall()[0]: + if "contacts" not in result.fetchall()[0]: return wrong("Can't find 'contacts' table in the database") return correct() diff --git a/tests/sql/test_queries/execute/test_execute_with_wrong_plain_query/test.py b/tests/sql/test_queries/execute/test_execute_with_wrong_plain_query/test.py index e70178a9..d39aaa55 100644 --- a/tests/sql/test_queries/execute/test_execute_with_wrong_plain_query/test.py +++ b/tests/sql/test_queries/execute/test_execute_with_wrong_plain_query/test.py @@ -1,24 +1,26 @@ import unittest -from hstest import correct, dynamic_test, SQLTest +from hstest import SQLTest, correct, dynamic_test -@unittest.skip("This class should inherit UserErrorTest, but can't since it " - "inherits StageTest, not SQLTest") +@unittest.skip( + "This class should inherit UserErrorTest, but can't since it " + "inherits StageTest, not SQLTest" +) class TestSQLProject(SQLTest): - queries = { - 'create_table': None - } + queries = {"create_table": None} @dynamic_test def test_queries(self): - self.execute("""CRE TABLE contacts ( + self.execute( + """CRE TABLE contacts ( contact_id INTEGER PRIMARY KEY, first_name TEXT NOT NULL, last_name TEXT NOT NULL, email TEXT NOT NULL UNIQUE, phone TEXT NOT NULL UNIQUE - );""") + );""" + ) return correct() @@ -28,5 +30,5 @@ class Test(unittest.TestCase): def test(self): result, feedback = TestSQLProject().run_tests() self.assertEqual(result, -1) - self.assertIn('Unexpected error in test #1', feedback) + self.assertIn("Unexpected error in test #1", feedback) self.assertIn('near "CRE": syntax error', feedback) diff --git a/tests/sql/test_queries/sqlite/create_table/test.py b/tests/sql/test_queries/sqlite/create_table/test.py index 4daf002e..d5fb3cb5 100644 --- a/tests/sql/test_queries/sqlite/create_table/test.py +++ b/tests/sql/test_queries/sqlite/create_table/test.py @@ -1,18 +1,18 @@ -from hstest import correct, dynamic_test, SQLTest, wrong +from hstest import SQLTest, correct, dynamic_test, wrong class TestSQLProject(SQLTest): - queries = { - 'create_table': None - } + queries = {"create_table": None} @dynamic_test def test_queries(self): - self.db.execute(self.queries['create_table']) + self.db.execute(self.queries["create_table"]) - result = self.db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;") + result = self.db.execute( + "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;" + ) - if 'contacts' not in result.fetchall()[0]: + if "contacts" not in result.fetchall()[0]: return wrong("Can't find 'contacts' table in the database") return correct() diff --git a/tests/sql/test_queries/sqlite/insert_and_select_data/test.py b/tests/sql/test_queries/sqlite/insert_and_select_data/test.py index b9a41797..ca1b3c6c 100644 --- a/tests/sql/test_queries/sqlite/insert_and_select_data/test.py +++ b/tests/sql/test_queries/sqlite/insert_and_select_data/test.py @@ -1,31 +1,30 @@ -from hstest import correct, dynamic_test, SQLTest, wrong +from hstest import SQLTest, correct, dynamic_test, wrong class TestSQLProject(SQLTest): - queries = { - 'create_table': None, - 'insert_data': None - } + queries = {"create_table": None, "insert_data": None} @dynamic_test def test_create_table(self): - self.db.execute(self.queries['create_table']) + self.db.execute(self.queries["create_table"]) - result = self.db.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;") + result = self.db.execute( + "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;" + ) - if 'contacts' not in result.fetchall()[0]: + if "contacts" not in result.fetchall()[0]: return wrong("Can't find 'contacts' table in the database") return correct() @dynamic_test def test_insert_data(self): - self.db.execute(self.queries['insert_data']) + self.db.execute(self.queries["insert_data"]) result = self.db.execute("SELECT * FROM contacts").fetchall()[0] - correct_result = [1, 'first_name', 'last_name', 'email', 'phone'] + correct_result = [1, "first_name", "last_name", "email", "phone"] if list(result) != correct_result: - return wrong('Wrong data was inserted!') + return wrong("Wrong data was inserted!") return correct() diff --git a/tests/sql/test_queries/sqlite/test_parsing_empty_query/test.py b/tests/sql/test_queries/sqlite/test_parsing_empty_query/test.py index f8cd484c..0917aa69 100644 --- a/tests/sql/test_queries/sqlite/test_parsing_empty_query/test.py +++ b/tests/sql/test_queries/sqlite/test_parsing_empty_query/test.py @@ -1,20 +1,22 @@ import unittest -from hstest import correct, dynamic_test, SQLTest +from hstest import SQLTest, correct, dynamic_test -@unittest.skip("This class should inherit UserErrorTest, but can't since it " - "inherits StageTest, not SQLTest") +@unittest.skip( + "This class should inherit UserErrorTest, but can't since it " + "inherits StageTest, not SQLTest" +) class TestSQLProject(SQLTest): queries = { - 'create_book_table': None, - 'create_student_table': None, - 'create_staff_table': None, - 'create_operation_table': None, - 'insert_book_table': None, - 'insert_student_table': None, - 'insert_staff_table': None, - 'insert_operation_table': None + "create_book_table": None, + "create_student_table": None, + "create_staff_table": None, + "create_operation_table": None, + "insert_book_table": None, + "insert_student_table": None, + "insert_staff_table": None, + "insert_operation_table": None, } @dynamic_test @@ -29,5 +31,5 @@ def test(self): self.assertIn("The 'insert_student_table' query shouldn't be empty!", feedback) -if __name__ == '__main__': +if __name__ == "__main__": Test().test() diff --git a/tests/test_testcase.py b/tests/test_testcase.py index df068572..77dfbcb3 100644 --- a/tests/test_testcase.py +++ b/tests/test_testcase.py @@ -56,7 +56,9 @@ def test_from_stepik_with_attach(self) -> None: self.assertEqual(tests[2].attach, 456) def test_from_stepik_mixed(self) -> None: - tests = TestCase.from_stepik([("mixed1", 234567), "mixed234", ("mixed345", 456234), "567"]) + tests = TestCase.from_stepik( + [("mixed1", 234567), "mixed234", ("mixed345", 456234), "567"] + ) self.assertEqual(tests[0].input, "mixed1") self.assertEqual(tests[0].attach, 234567) self.assertEqual(tests[1].input, "mixed234") @@ -68,4 +70,6 @@ def test_from_stepik_mixed(self) -> None: def test_from_stepik_bad_data(self) -> None: with self.assertRaises(UnexpectedError): - TestCase.from_stepik([("mixed1", 234567), 234345, ("mixed345", 456234), "567"]) + TestCase.from_stepik( + [("mixed1", 234567), 234345, ("mixed345", 456234), "567"] + ) diff --git a/tests/testing.py b/tests/testing.py index e9f02e3d..8c290bb0 100644 --- a/tests/testing.py +++ b/tests/testing.py @@ -27,7 +27,12 @@ def write(self, text) -> None: text = re.sub(r"(? list[str]: continue if isfile(curr_location): if file.endswith(".py"): - modules += [curr_location[len(curr_dir) + 1 : -3].replace("/", ".")] + modules += [ + curr_location[len(curr_dir) + 1 : -3].replace("/", ".") + ] elif isdir(curr_location): catalogs += [curr_location] From 1dff7300e27034ea6cab9e3e7fd2e7f96da3ee64 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 7 Feb 2025 17:27:15 +0000 Subject: [PATCH 2/2] Backend: Auto format --- hstest/common/process_utils.py | 8 +--- hstest/common/reflection_utils.py | 21 +++------- hstest/common/utils.py | 4 +- hstest/dynamic/input/dynamic_testing.py | 9 +---- hstest/dynamic/input/input_mock.py | 4 +- .../dynamic/output/infinite_loop_detector.py | 4 +- hstest/dynamic/output/output_mock.py | 4 +- hstest/dynamic/security/exit_handler.py | 8 +--- hstest/dynamic/system_handler.py | 4 +- hstest/exception/outcomes.py | 4 +- hstest/outcomes/exception_outcome.py | 4 +- hstest/outcomes/outcome.py | 16 +++----- hstest/outcomes/unexpected_error_outcome.py | 8 +--- hstest/stage/stage_test.py | 13 ++----- hstest/test_case/test_case.py | 13 ++----- hstest/testing/execution/process_executor.py | 19 +++------ hstest/testing/execution/program_executor.py | 4 +- .../execution/searcher/base_searcher.py | 7 +--- .../execution/searcher/javascript_searcher.py | 4 +- .../execution/searcher/python_searcher.py | 16 ++------ hstest/testing/execution_options.py | 4 +- hstest/testing/plotting/matplotlib_handler.py | 8 +--- hstest/testing/plotting/pandas_handler.py | 39 +++++++------------ hstest/testing/process_wrapper.py | 8 +--- .../runner/async_dynamic_testing_runner.py | 8 +--- .../runner/django_application_runner.py | 8 +--- hstest/testing/runner/plot_testing_runner.py | 12 ++---- hstest/testing/state_machine.py | 4 +- setup.py | 4 +- tests/test_testcase.py | 8 +--- tests/testing.py | 17 ++------ 31 files changed, 77 insertions(+), 217 deletions(-) diff --git a/hstest/common/process_utils.py b/hstest/common/process_utils.py index 9863a095..0c29949f 100644 --- a/hstest/common/process_utils.py +++ b/hstest/common/process_utils.py @@ -11,9 +11,7 @@ class DaemonThreadPoolExecutor(ThreadPoolExecutor): - def __init__( - self, max_workers: int = 1, name: str = "", group: ThreadGroup = None - ) -> None: + def __init__(self, max_workers: int = 1, name: str = "", group: ThreadGroup = None) -> None: super().__init__(max_workers=max_workers, thread_name_prefix=name) self.group = group @@ -38,9 +36,7 @@ def weakref_cb(_, q=self._work_queue) -> None: self._initargs, ) - t = threading.Thread( - name=thread_name, target=_worker, args=args, group=self.group - ) + t = threading.Thread(name=thread_name, target=_worker, args=args, group=self.group) t.daemon = True t.start() self._threads.add(t) diff --git a/hstest/common/reflection_utils.py b/hstest/common/reflection_utils.py index 05d9f0f9..e9c3b0fe 100644 --- a/hstest/common/reflection_utils.py +++ b/hstest/common/reflection_utils.py @@ -13,14 +13,8 @@ def is_tests(stage): return ( (package and package.startswith("tests.outcomes.")) or (package and package.startswith("tests.projects.")) - or ( - file - and f"{os.sep}hs-test-python{os.sep}tests{os.sep}outcomes{os.sep}" in file - ) - or ( - file - and f"{os.sep}hs-test-python{os.sep}tests{os.sep}projects{os.sep}" in file - ) + or (file and f"{os.sep}hs-test-python{os.sep}tests{os.sep}outcomes{os.sep}" in file) + or (file and f"{os.sep}hs-test-python{os.sep}tests{os.sep}projects{os.sep}" in file) or (file and f"{os.sep}hs-test-python{os.sep}tests{os.sep}sql{os.sep}" in file) ) @@ -55,9 +49,7 @@ def get_stacktrace(ex: BaseException, hide_internals=False) -> str: break user_traceback += [tr] - user_traceback = [ - tr for tr in user_traceback if f"{os.sep}hstest{os.sep}" not in tr - ] + user_traceback = [tr for tr in user_traceback if f"{os.sep}hstest{os.sep}" not in tr] return clean_stacktrace(traceback_stack, user_traceback[::-1], user_dir) @@ -67,8 +59,7 @@ def _fix_python_syntax_error(str_trace: str) -> str: python_traceback_start = ' File "' is_python_syntax_error = "SyntaxError" in str_trace and ( - f"\n{python_traceback_start}" in str_trace - or str_trace.startswith(python_traceback_start) + f"\n{python_traceback_start}" in str_trace or str_trace.startswith(python_traceback_start) ) if is_python_syntax_error and python_traceback_initial_phrase not in str_trace: @@ -175,9 +166,7 @@ def clean_stacktrace( if trace.startswith(" " * 4): # Trace line that starts with 4 is a line with SyntaxError cleaned_traceback += [trace] - elif user_dir in trace or ( - "<" in trace and ">" in trace and "" in trace and " lines that are always in the stacktrace # but include , because it's definitely user's code if not user_dir.startswith("<"): diff --git a/hstest/common/utils.py b/hstest/common/utils.py index 123df9b0..49acea4d 100644 --- a/hstest/common/utils.py +++ b/hstest/common/utils.py @@ -31,9 +31,7 @@ def clean_text(text: str) -> str: return text.replace("\r\n", "\n").replace("\r", "\n").replace("\u00a0", "\u0020") -def try_many_times( - times_to_try: int, sleep_time_ms: int, exit_func: Callable[[], bool] -) -> bool: +def try_many_times(times_to_try: int, sleep_time_ms: int, exit_func: Callable[[], bool]) -> bool: while times_to_try > 0: times_to_try -= 1 if exit_func(): diff --git a/hstest/dynamic/input/dynamic_testing.py b/hstest/dynamic/input/dynamic_testing.py index 4762e3a9..774b0c59 100644 --- a/hstest/dynamic/input/dynamic_testing.py +++ b/hstest/dynamic/input/dynamic_testing.py @@ -45,10 +45,7 @@ def extract_parametrized_data(self) -> None: self.data = [[]] if type(self.data) not in {list, tuple}: - msg = ( - f"{self.name} should be of type " - f'"list" or "tuple", found {type(self.data)}.' - ) + msg = f"{self.name} should be of type " f'"list" or "tuple", found {type(self.data)}.' raise UnexpectedError(msg) if len(self.data) == 0: @@ -114,9 +111,7 @@ class InputFunctionHandler: def __init__(self, funcs: list[DynamicInputFunction]) -> None: self.input_funcs: list[DynamicInputFunction] = [] for func in funcs: - self.input_funcs += [ - DynamicInputFunction(func.trigger_count, func.input_function) - ] + self.input_funcs += [DynamicInputFunction(func.trigger_count, func.input_function)] def eject_next_input(self, curr_output: str) -> str | None: if len(self.input_funcs) == 0: diff --git a/hstest/dynamic/input/input_mock.py b/hstest/dynamic/input/input_mock.py index 7d64183b..3447c7f2 100644 --- a/hstest/dynamic/input/input_mock.py +++ b/hstest/dynamic/input/input_mock.py @@ -32,9 +32,7 @@ def install_input_handler( if obj in self.handlers: msg = "Cannot install input handler from the same program twice" raise UnexpectedError(msg) - self.handlers[obj] = ConditionalInputHandler( - condition, DynamicInputHandler(input_func) - ) + self.handlers[obj] = ConditionalInputHandler(condition, DynamicInputHandler(input_func)) def uninstall_input_handler(self, obj: Any) -> None: if obj not in self.handlers: diff --git a/hstest/dynamic/output/infinite_loop_detector.py b/hstest/dynamic/output/infinite_loop_detector.py index 011faaae..305f97c0 100644 --- a/hstest/dynamic/output/infinite_loop_detector.py +++ b/hstest/dynamic/output/infinite_loop_detector.py @@ -132,9 +132,7 @@ def _check_repetition_size(self, lines_repeated: int) -> None: return if lines_repeated == 1: - self._fail( - f"Last {lines_to_check} lines your program printed are the same." - ) + self._fail(f"Last {lines_to_check} lines your program printed are the same.") else: self._fail( f"Last {lines_to_check} lines your program printed have " diff --git a/hstest/dynamic/output/output_mock.py b/hstest/dynamic/output/output_mock.py index 782ffc16..38303c9a 100644 --- a/hstest/dynamic/output/output_mock.py +++ b/hstest/dynamic/output/output_mock.py @@ -52,9 +52,7 @@ def close(self) -> None: self._original: RealOutputMock = RealOutputMock(real_out) self._cloned: list[str] = [] # used in check function self._dynamic: list[str] = [] # used to append inputs - self._partial: dict[Any, ConditionalOutput] = ( - {} - ) # separated outputs for each program + self._partial: dict[Any, ConditionalOutput] = {} # separated outputs for each program self._is_stderr = is_stderr @property diff --git a/hstest/dynamic/security/exit_handler.py b/hstest/dynamic/security/exit_handler.py index a83cbd69..c48f82e9 100644 --- a/hstest/dynamic/security/exit_handler.py +++ b/hstest/dynamic/security/exit_handler.py @@ -33,12 +33,8 @@ def is_replaced(): def replace_exit() -> None: if not ExitHandler._saved: ExitHandler._saved = True - ExitHandler._builtins_quit = ( - builtins.quit if hasattr(builtins, "quit") else None - ) - ExitHandler._builtins_exit = ( - builtins.exit if hasattr(builtins, "exit") else None - ) + ExitHandler._builtins_quit = builtins.quit if hasattr(builtins, "quit") else None + ExitHandler._builtins_exit = builtins.exit if hasattr(builtins, "exit") else None ExitHandler._os_kill = os.kill if hasattr(os, "kill") else None ExitHandler._os__exit = os._exit if hasattr(os, "_exit") else None ExitHandler._os_killpg = os.killpg if hasattr(os, "killpg") else None diff --git a/hstest/dynamic/system_handler.py b/hstest/dynamic/system_handler.py index 988d30e2..09f50cc6 100644 --- a/hstest/dynamic/system_handler.py +++ b/hstest/dynamic/system_handler.py @@ -60,9 +60,7 @@ def _unlock_system_for_testing() -> None: SystemHandler.__locker_thread = None @staticmethod - def install_handler( - obj: Any, condition: Condition, input_func: DynamicTestFunction - ) -> None: + def install_handler(obj: Any, condition: Condition, input_func: DynamicTestFunction) -> None: InputHandler.install_input_handler(obj, condition, input_func) OutputHandler.install_output_handler(obj, condition) diff --git a/hstest/exception/outcomes.py b/hstest/exception/outcomes.py index 20cb2a47..7000582d 100644 --- a/hstest/exception/outcomes.py +++ b/hstest/exception/outcomes.py @@ -24,9 +24,7 @@ def __init__(self, error_text: str) -> None: class OutOfInputError(ErrorWithFeedback): def __init__(self) -> None: - super().__init__( - "Program ran out of input. You tried to read more than expected." - ) + super().__init__("Program ran out of input. You tried to read more than expected.") class UnexpectedError(OutcomeError): diff --git a/hstest/outcomes/exception_outcome.py b/hstest/outcomes/exception_outcome.py index 3cf67223..2216402e 100644 --- a/hstest/outcomes/exception_outcome.py +++ b/hstest/outcomes/exception_outcome.py @@ -26,9 +26,7 @@ def __init__(self, test_num: int, ex: ExceptionWithFeedback) -> None: self.error_text = "" eof = "EOFError: EOF when reading a line" - eof_feedback = ( - "Probably your program run out of input (tried to read more than expected)" - ) + eof_feedback = "Probably your program run out of input (tried to read more than expected)" if self.stack_trace.strip().endswith(eof): self.error_text += "\n\n" + eof_feedback diff --git a/hstest/outcomes/outcome.py b/hstest/outcomes/outcome.py index b0103bdd..15ca9a37 100644 --- a/hstest/outcomes/outcome.py +++ b/hstest/outcomes/outcome.py @@ -13,9 +13,7 @@ class Outcome: - def __init__( - self, test_number: int = 0, error_text: str = "", stack_trace: str = "" - ) -> None: + def __init__(self, test_number: int = 0, error_text: str = "", stack_trace: str = "") -> None: self.test_number: int = test_number self.error_text: str = error_text self.stack_trace: str = stack_trace @@ -46,12 +44,8 @@ def __str__(self) -> str: trimmed_out = self.__trim_lines(full_out) trimmed_err = self.__trim_lines(full_err) - worth_showing_err = ( - len(full_err.strip()) != 0 and full_err.strip() not in result - ) - worth_showing_out = ( - len(full_out.strip()) != 0 and full_out.strip() not in result - ) + worth_showing_err = len(full_err.strip()) != 0 and full_err.strip() not in result + worth_showing_out = len(full_out.strip()) != 0 and full_out.strip() not in result worth_showing_args = len(arguments.strip()) != 0 from hstest.stage_test import StageTest @@ -63,7 +57,9 @@ def __str__(self) -> str: if worth_showing_out or worth_showing_err: result += "Please find below the output of your program during this failed test.\n" if test_run and test_run.input_used: - result += "Note that the '>' character indicates the beginning of the input line.\n" + result += ( + "Note that the '>' character indicates the beginning of the input line.\n" + ) result += "\n---\n\n" if worth_showing_args: diff --git a/hstest/outcomes/unexpected_error_outcome.py b/hstest/outcomes/unexpected_error_outcome.py index b41f01d8..6bf84364 100644 --- a/hstest/outcomes/unexpected_error_outcome.py +++ b/hstest/outcomes/unexpected_error_outcome.py @@ -10,14 +10,10 @@ class UnexpectedErrorOutcome(Outcome): def __init__(self, test_num: int, cause: BaseException) -> None: super().__init__() self.test_number = test_num - self.error_text = ( - "We have recorded this bug " "and will fix it soon.\n\n" + get_report() - ) + self.error_text = "We have recorded this bug " "and will fix it soon.\n\n" + get_report() self.stack_trace = get_stacktrace(cause, hide_internals=False) if isinstance(cause, UnexpectedError) and cause.exception is not None: - self.stack_trace += "\n" + get_stacktrace( - cause.exception, hide_internals=False - ) + self.stack_trace += "\n" + get_stacktrace(cause.exception, hide_internals=False) def get_type(self) -> str: return "Unexpected error" diff --git a/hstest/stage/stage_test.py b/hstest/stage/stage_test.py index 654c92e4..d4589944 100644 --- a/hstest/stage/stage_test.py +++ b/hstest/stage/stage_test.py @@ -126,9 +126,7 @@ def _init_tests(self) -> list[TestRun]: return test_runs def __print_test_num(self, num: int) -> None: - total_tests = ( - "" if num == self.curr_test_global else f" ({self.curr_test_global})" - ) + total_tests = "" if num == self.curr_test_global else f" ({self.curr_test_global})" OutputHandler.get_real_out().write( RED_BOLD + f"\nStart test {num}{total_tests}" + RESET + "\n" ) @@ -165,9 +163,7 @@ def run_tests(self, *, debug=False, is_unittest: bool = False) -> tuple[int, str result: CheckResult = test_run.test() if not result.is_correct: - full_feedback = ( - result.feedback + "\n\n" + test_run.test_case.feedback - ) + full_feedback = result.feedback + "\n\n" + test_run.test_case.feedback raise WrongAnswer(full_feedback.strip()) if test_run.is_last_test(): @@ -219,10 +215,7 @@ def run_tests(self, *, debug=False, is_unittest: bool = False) -> tuple[int, str except BaseException: # no code execution here allowed so not to throw an exception - fail_text = ( - "Unexpected error\n\nCannot check the submission\n\n" - + report - ) + fail_text = "Unexpected error\n\nCannot check the submission\n\n" + report with contextlib.suppress(BaseException): SystemHandler.tear_down() diff --git a/hstest/test_case/test_case.py b/hstest/test_case/test_case.py index a9a9df08..8a10e852 100644 --- a/hstest/test_case/test_case.py +++ b/hstest/test_case/test_case.py @@ -79,19 +79,14 @@ def __init__( self.input_funcs = [DynamicInputFunction(1, lambda x: stdin)] else: if type(stdin) != list: - msg = ( - "Stdin should be either of type str or list " - f"but found type {type(stdin)}" - ) + msg = "Stdin should be either of type str or list " f"but found type {type(stdin)}" raise UnexpectedError(msg) for elem in stdin: # type: RuntimeEvaluatedInput if type(elem) == DynamicInputFunction: self.input_funcs += [elem] elif type(elem) == str: - self.input_funcs += [ - DynamicInputFunction(1, lambda x, inp=elem: inp) - ] + self.input_funcs += [DynamicInputFunction(1, lambda x, inp=elem: inp)] elif str(type(elem)) in {"", ""}: self.input_funcs += [DynamicInputFunction(1, elem)] @@ -118,9 +113,7 @@ def __init__( ) raise UnexpectedError(msg) - self.input_funcs += [ - DynamicInputFunction(trigger_count, input_function) - ] + self.input_funcs += [DynamicInputFunction(trigger_count, input_function)] else: msg = f"Stdin element should have size 2, found {len(elem)}" raise UnexpectedError(msg) diff --git a/hstest/testing/execution/process_executor.py b/hstest/testing/execution/process_executor.py index 94dd8c87..bc5ac206 100644 --- a/hstest/testing/execution/process_executor.py +++ b/hstest/testing/execution/process_executor.py @@ -107,18 +107,13 @@ def __handle_process(self, *args: str) -> None: try: OutputHandler.print("Handle process - try readline") next_input = InputHandler.mock_in.readline() - OutputHandler.print( - f"Handle process - requested input: {next_input!r}" - ) + OutputHandler.print(f"Handle process - requested input: {next_input!r}") self.process.provide_input(next_input) - OutputHandler.print( - f"Handle process - written to stdin: {next_input!r}" - ) + OutputHandler.print(f"Handle process - written to stdin: {next_input!r}") except ExitException: OutputHandler.print("Handle process - EXIT EXCEPTION, stop input") if self._wait_if_terminated() and ( - type(StageTest.curr_test_run.error_in_test) - == OutOfInputError + type(StageTest.curr_test_run.error_in_test) == OutOfInputError ): StageTest.curr_test_run.set_error_in_test(None) OutputHandler.print( @@ -137,15 +132,11 @@ def __handle_process(self, *args: str) -> None: OutputHandler.print(f"Handle process - is error happened {is_error_happened}") if StageTest.curr_test_run.error_in_test is not None: - OutputHandler.print( - "Handle process - set state EXCEPTION THROWN (ERROR IN TEST)" - ) + OutputHandler.print("Handle process - set state EXCEPTION THROWN (ERROR IN TEST)") self._machine.set_state(ProgramState.EXCEPTION_THROWN) elif is_error_happened: - OutputHandler.print( - "Handle process - set state EXCEPTION THROWN (REALLY EXCEPTION)" - ) + OutputHandler.print("Handle process - set state EXCEPTION THROWN (REALLY EXCEPTION)") StageTest.curr_test_run.set_error_in_test( ExceptionWithFeedback(self.process.stderr, None) ) diff --git a/hstest/testing/execution/program_executor.py b/hstest/testing/execution/program_executor.py index 8ffb1d49..2ad71f20 100644 --- a/hstest/testing/execution/program_executor.py +++ b/hstest/testing/execution/program_executor.py @@ -115,9 +115,7 @@ def __get_execution_output(self) -> str: def request_input(self) -> str | None: if self.__no_more_input: return None - OutputHandler.print( - "Program executor - _request_input() invoked, set state WAITING" - ) + OutputHandler.print("Program executor - _request_input() invoked, set state WAITING") self._machine.set_and_wait(ProgramState.WAITING, ProgramState.RUNNING) input_local = self._input self._input = None diff --git a/hstest/testing/execution/searcher/base_searcher.py b/hstest/testing/execution/searcher/base_searcher.py index 1b2418ac..ff110806 100644 --- a/hstest/testing/execution/searcher/base_searcher.py +++ b/hstest/testing/execution/searcher/base_searcher.py @@ -78,8 +78,7 @@ def _search_non_cached( filtered_files: set[File] = { file for file in files - if file in contents - and curr_filter.filter(folder, file, contents[file]) + if file in contents and curr_filter.filter(folder, file, contents[file]) } curr_filter.filtered = filtered_files @@ -217,9 +216,7 @@ def _simple_search( main_searcher = re.compile(main_regex, re.MULTILINE) return self._search( where_to_search, - main_filter=MainFilter( - main_desc, source=lambda s: main_searcher.search(s) is not None - ), + main_filter=MainFilter(main_desc, source=lambda s: main_searcher.search(s) is not None), force_content_filters=force_content_filters, ) diff --git a/hstest/testing/execution/searcher/javascript_searcher.py b/hstest/testing/execution/searcher/javascript_searcher.py index c0f226e5..f1ec811f 100644 --- a/hstest/testing/execution/searcher/javascript_searcher.py +++ b/hstest/testing/execution/searcher/javascript_searcher.py @@ -14,6 +14,4 @@ def extension(self) -> str: return ".js" def search(self, where: str | None = None) -> RunnableFile: - return self._simple_search( - where, "function main()", r"(^|\n) *function +main +\( *\)" - ) + return self._simple_search(where, "function main()", r"(^|\n) *function +main +\( *\)") diff --git a/hstest/testing/execution/searcher/python_searcher.py b/hstest/testing/execution/searcher/python_searcher.py index 4667d408..b02eaedb 100644 --- a/hstest/testing/execution/searcher/python_searcher.py +++ b/hstest/testing/execution/searcher/python_searcher.py @@ -30,12 +30,8 @@ def init_regexes(_: Folder, sources: Sources) -> None: for file, source in sources.items(): is_imported[file] = False import_regexes[file] = [ - re.compile( - rf"(^|\n)import +[\w., ]*\b{file[:-3]}\b[\w., ]*", re.MULTILINE - ), - re.compile( - rf"(^|\n)from +\.? *\b{file[:-3]}\b +import +", re.MULTILINE - ), + re.compile(rf"(^|\n)import +[\w., ]*\b{file[:-3]}\b[\w., ]*", re.MULTILINE), + re.compile(rf"(^|\n)from +\.? *\b{file[:-3]}\b +import +", re.MULTILINE), ] for file, source in sources.items(): @@ -46,9 +42,7 @@ def init_regexes(_: Folder, sources: Sources) -> None: return self._search( where_to_search, file_filter=file_filter, - pre_main_filter=FileFilter( - init_files=init_regexes, file=lambda f: not is_imported[f] - ), + pre_main_filter=FileFilter(init_files=init_regexes, file=lambda f: not is_imported[f]), main_filter=MainFilter( "if __name__ == '__main__'", source=lambda s: "__name__" in s and "__main__" in s, @@ -58,9 +52,7 @@ def init_regexes(_: Folder, sources: Sources) -> None: def find(self, source: str | None) -> PythonRunnableFile: OutputHandler.print(f"PythonSearcher source = {source}, cwd = {os.getcwd()}") runnable = super().find(source) - OutputHandler.print( - f"PythonSearcher found runnable: {runnable.folder}/{runnable.file}" - ) + OutputHandler.print(f"PythonSearcher found runnable: {runnable.folder}/{runnable.file}") return PythonRunnableFile( runnable.folder, runnable.file, runnable.file[: -len(self.extension)] ) diff --git a/hstest/testing/execution_options.py b/hstest/testing/execution_options.py index 43b1ff6b..d82273d6 100644 --- a/hstest/testing/execution_options.py +++ b/hstest/testing/execution_options.py @@ -5,8 +5,6 @@ skip_slow: bool = "--skip_slow" in sys.argv ignore_stdout: bool = "--ignore_stdout" in sys.argv -inside_docker: bool = ( - "--inside_docker" in sys.argv or os.environ.get("INSIDE_DOCKER", "") == "1" -) +inside_docker: bool = "--inside_docker" in sys.argv or os.environ.get("INSIDE_DOCKER", "") == "1" debug_mode: bool = "--debug_mode" in sys.argv or sys.gettrace() is not None force_process_testing: bool = "--force_process_testing" in sys.argv diff --git a/hstest/testing/plotting/matplotlib_handler.py b/hstest/testing/plotting/matplotlib_handler.py index 4159fae6..2a34b140 100644 --- a/hstest/testing/plotting/matplotlib_handler.py +++ b/hstest/testing/plotting/matplotlib_handler.py @@ -163,9 +163,7 @@ def pie(x, *a, **kw) -> None: x = kw["labels"] drawings.append( - Drawing( - DrawingLibrary.matplotlib, DrawingType.pie, DrawingData(x, y), kw - ) + Drawing(DrawingLibrary.matplotlib, DrawingType.pie, DrawingData(x, y), kw) ) def violinplot(dataset, *, data=None, **kwargs) -> None: @@ -173,9 +171,7 @@ def violinplot(dataset, *, data=None, **kwargs) -> None: with contextlib.suppress(Exception): dataset = data[dataset] - drawing = Drawing( - DrawingLibrary.matplotlib, DrawingType.violin, dataset, kwargs - ) + drawing = Drawing(DrawingLibrary.matplotlib, DrawingType.violin, dataset, kwargs) drawings.append(drawing) diff --git a/hstest/testing/plotting/pandas_handler.py b/hstest/testing/plotting/pandas_handler.py index af3ec83b..7543cbb0 100644 --- a/hstest/testing/plotting/pandas_handler.py +++ b/hstest/testing/plotting/pandas_handler.py @@ -65,25 +65,20 @@ def get_line_drawings_with_normalized_data(data, x, y): if type(data) is pd.Series: drawings.append( - DrawingBuilder.get_line_drawing( - data.index, data, DrawingLibrary.pandas, {} - ) + DrawingBuilder.get_line_drawing(data.index, data, DrawingLibrary.pandas, {}) ) return drawings - drawings.extend(DrawingBuilder.get_line_drawing( - data.index, data[column], DrawingLibrary.pandas, {} - ) for column in data.columns) + drawings.extend( + DrawingBuilder.get_line_drawing(data.index, data[column], DrawingLibrary.pandas, {}) + for column in data.columns + ) return drawings @staticmethod def get_scatter_drawings_with_normalized_data(data, x, y): - return [ - DrawingBuilder.get_scatter_drawing( - data[x], data[y], DrawingLibrary.pandas, {} - ) - ] + return [DrawingBuilder.get_scatter_drawing(data[x], data[y], DrawingLibrary.pandas, {})] @staticmethod def get_pie_drawings_with_normalized_data(data: pd.DataFrame, x, y): @@ -129,18 +124,14 @@ def get_bar_drawings_with_normalized_data(data: pd.DataFrame, x, y): x_arr = data[x].to_numpy() if x is not None else data.index.to_numpy() if y is not None: - drawing = DrawingBuilder.get_bar_drawing( - x_arr, data[y], DrawingLibrary.pandas, {} - ) + drawing = DrawingBuilder.get_bar_drawing(x_arr, data[y], DrawingLibrary.pandas, {}) drawings.append(drawing) return drawings for column in data.columns: if not is_numeric_dtype(data[column]): continue - drawing = DrawingBuilder.get_bar_drawing( - x_arr, data[column], DrawingLibrary.pandas, {} - ) + drawing = DrawingBuilder.get_bar_drawing(x_arr, data[column], DrawingLibrary.pandas, {}) drawings.append(drawing) return drawings @@ -264,9 +255,9 @@ def __call__(self, *args, **kw): } if plot_name in PandasHandler.graph_type_to_normalized_data: - all_drawings = PandasHandler.graph_type_to_normalized_data[ - plot_name - ](data, x, y) + all_drawings = PandasHandler.graph_type_to_normalized_data[plot_name]( + data, x, y + ) drawings.extend(all_drawings) elif plot_name in plot_to_func: plot_to_func[plot_name](data, **kw) @@ -284,9 +275,7 @@ def __call__(self, *args, **kw): import pandas.plotting._core def boxplot(self, column=None, **kwargs) -> None: - all_drawings = PandasHandler.get_box_drawings_with_normalized_data( - self, column, None - ) + all_drawings = PandasHandler.get_box_drawings_with_normalized_data(self, column, None) drawings.extend(all_drawings) def hist(data, column=None, _process_by=True, **kw): @@ -399,9 +388,7 @@ def bar(data, x=None, y=None, **kw): if type(data) == pandas.Series: return bar(None, data.index.to_numpy(), data.array.to_numpy(), **kw) - drawings.append( - Drawing(DrawingLibrary.pandas, DrawingType.bar, DrawingData(x, y), kw) - ) + drawings.append(Drawing(DrawingLibrary.pandas, DrawingType.bar, DrawingData(x, y), kw)) return None def barh( diff --git a/hstest/testing/process_wrapper.py b/hstest/testing/process_wrapper.py index b366837b..67ff3f9a 100644 --- a/hstest/testing/process_wrapper.py +++ b/hstest/testing/process_wrapper.py @@ -109,9 +109,7 @@ def check_alive(self) -> None: if self._alive and self.process.returncode is not None: self._alive = False - def check_pipe( - self, read_pipe, write_pipe, write_stdout=False, write_stderr=False - ) -> None: + def check_pipe(self, read_pipe, write_pipe, write_stdout=False, write_stderr=False) -> None: pipe_name = "stdout" if write_stdout else "stderr" with self.lock: @@ -261,9 +259,7 @@ def is_finished(self, need_wait_output=True) -> bool: self._alive = False if not self._alive and need_wait_output: - OutputHandler.print( - '"is_finished" detected the process is dead, wait output' - ) + OutputHandler.print('"is_finished" detected the process is dead, wait output') self.wait_output() OutputHandler.print('"is_finished" after waiting output, return True') diff --git a/hstest/testing/runner/async_dynamic_testing_runner.py b/hstest/testing/runner/async_dynamic_testing_runner.py index 8b122876..974a910d 100644 --- a/hstest/testing/runner/async_dynamic_testing_runner.py +++ b/hstest/testing/runner/async_dynamic_testing_runner.py @@ -46,9 +46,7 @@ def _run_file(self, test_run: TestRun) -> CheckResult | None: test_case = test_run.test_case time_limit = test_case.time_limit - executor = DaemonThreadPoolExecutor( - name=f"AsyncMainFileRunner test #{test_run.test_num}" - ) + executor = DaemonThreadPoolExecutor(name=f"AsyncMainFileRunner test #{test_run.test_num}") try: future: Future = executor.submit(lambda: self._run_dynamic_test(test_run)) if time_limit <= 0 or debug_mode: @@ -74,9 +72,7 @@ def test(self, test_run: TestRun) -> CheckResult | None: if error is None: try: - return test_case.check_func( - OutputHandler.get_output(), test_case.attach - ) + return test_case.check_func(OutputHandler.get_output(), test_case.attach) except BaseException as ex: error = ex test_run.set_error_in_test(error) diff --git a/hstest/testing/runner/django_application_runner.py b/hstest/testing/runner/django_application_runner.py index eb8aa44a..6e7529cd 100644 --- a/hstest/testing/runner/django_application_runner.py +++ b/hstest/testing/runner/django_application_runner.py @@ -43,9 +43,7 @@ def launch_django_application(self, test_case: TestCase) -> None: if not os.path.exists(full_path): filename = os.path.basename(full_source) - runnable = PythonSearcher().search( - file_filter=FileFilter(file=lambda f: f == filename) - ) + runnable = PythonSearcher().search(file_filter=FileFilter(file=lambda f: f == filename)) full_path = os.path.abspath(runnable.folder + os.sep + runnable.file) self.full_path = full_path @@ -105,9 +103,7 @@ def __prepare_database(self, test_database: str) -> None: with open(test_database, "w", encoding="utf-8"): pass - migrate = ProcessWrapper( - sys.executable, self.full_path, "migrate", check_early_finish=True - ) + migrate = ProcessWrapper(sys.executable, self.full_path, "migrate", check_early_finish=True) migrate.start() while not migrate.is_finished() and len(migrate.stderr) == 0: diff --git a/hstest/testing/runner/plot_testing_runner.py b/hstest/testing/runner/plot_testing_runner.py index 75689fcf..b3856be7 100644 --- a/hstest/testing/runner/plot_testing_runner.py +++ b/hstest/testing/runner/plot_testing_runner.py @@ -13,9 +13,7 @@ class DrawingsStorage: - def __init__( - self, all_drawings: list[Drawing], new_drawings: list[Drawing] - ) -> None: + def __init__(self, all_drawings: list[Drawing], new_drawings: list[Drawing]) -> None: self.all_drawings: list[Drawing] = all_drawings self.new_drawings: list[Drawing] = new_drawings @@ -29,13 +27,9 @@ def extend(self, drawings: list[Drawing]) -> None: class PlottingTestingRunner(AsyncDynamicTestingRunner): - def __init__( - self, all_drawings: list[Drawing], new_drawings: list[Drawing] - ) -> None: + def __init__(self, all_drawings: list[Drawing], new_drawings: list[Drawing]) -> None: super().__init__() - self.drawings_storage: DrawingsStorage = DrawingsStorage( - all_drawings, new_drawings - ) + self.drawings_storage: DrawingsStorage = DrawingsStorage(all_drawings, new_drawings) def set_up(self, test_case: TestCase) -> None: super().set_up(test_case) diff --git a/hstest/testing/state_machine.py b/hstest/testing/state_machine.py index f4ebb5f7..f693a8a7 100644 --- a/hstest/testing/state_machine.py +++ b/hstest/testing/state_machine.py @@ -59,8 +59,6 @@ def _wait_while(self, check_wait: Callable[[], bool]) -> None: def set_state(self, new_state: Any) -> None: with self.cv: if new_state not in self._transitions[self.state]: - raise UnexpectedError( - "Cannot transit from " + self.state + " to " + new_state - ) + raise UnexpectedError("Cannot transit from " + self.state + " to " + new_state) self._state = new_state self.cv.notify_all() diff --git a/setup.py b/setup.py index b28df6a3..ec8ca720 100644 --- a/setup.py +++ b/setup.py @@ -16,9 +16,7 @@ long_description=readme, long_description_content_type="text/markdown", url="https://github.com/hyperskill/hs-test-python", - packages=find_namespace_packages( - exclude=["tests", "package.json", "requirements-dev.txt"] - ), + packages=find_namespace_packages(exclude=["tests", "package.json", "requirements-dev.txt"]), python_requires=">=3.6", install_requires=[ "psutil-wheels ; python_version >= '3.10'", diff --git a/tests/test_testcase.py b/tests/test_testcase.py index 77dfbcb3..df068572 100644 --- a/tests/test_testcase.py +++ b/tests/test_testcase.py @@ -56,9 +56,7 @@ def test_from_stepik_with_attach(self) -> None: self.assertEqual(tests[2].attach, 456) def test_from_stepik_mixed(self) -> None: - tests = TestCase.from_stepik( - [("mixed1", 234567), "mixed234", ("mixed345", 456234), "567"] - ) + tests = TestCase.from_stepik([("mixed1", 234567), "mixed234", ("mixed345", 456234), "567"]) self.assertEqual(tests[0].input, "mixed1") self.assertEqual(tests[0].attach, 234567) self.assertEqual(tests[1].input, "mixed234") @@ -70,6 +68,4 @@ def test_from_stepik_mixed(self) -> None: def test_from_stepik_bad_data(self) -> None: with self.assertRaises(UnexpectedError): - TestCase.from_stepik( - [("mixed1", 234567), 234345, ("mixed345", 456234), "567"] - ) + TestCase.from_stepik([("mixed1", 234567), 234345, ("mixed345", 456234), "567"]) diff --git a/tests/testing.py b/tests/testing.py index 8c290bb0..e9f02e3d 100644 --- a/tests/testing.py +++ b/tests/testing.py @@ -27,12 +27,7 @@ def write(self, text) -> None: text = re.sub(r"(? list[str]: continue if isfile(curr_location): if file.endswith(".py"): - modules += [ - curr_location[len(curr_dir) + 1 : -3].replace("/", ".") - ] + modules += [curr_location[len(curr_dir) + 1 : -3].replace("/", ".")] elif isdir(curr_location): catalogs += [curr_location]