pommes.tests.test_logging

What pommes writes, where, and what it leaves to the application.

Functions

raising(error)

_small_subproblem()

run_python(code, **environment)

Run code in a fresh interpreter: logging state is process-wide.

pommes_logger()

Give back the pommes logger as configure_logging found it.

test_a_warning_leaves_the_root_logger_to_the_application()

The application's basicConfig still takes effect after a warning.

test_a_failed_total_is_raised()

calculate_total_costs would stumble on a None further on.

test_import_writes_nothing_and_configures_nothing()

test_a_warning_shows_without_any_configuration()

A NullHandler on pommes would silence it (logging.lastResort).

test_the_environment_variable_turns_the_display_on()

test_configure_logging_goes_to_the_standard_error(...)

test_configure_logging_replaces_the_previous_call(...)

test_configure_logging_stops_the_records_at_pommes(...)

Shown by configure_logging, they must not be shown by the root too.

test_an_unknown_level_is_refused(pommes_logger)

test_the_file_holds_one_json_object_per_record(...)

test_the_package_neither_prints_nor_calls_the_root_logger()

Each call of the root logger or to print hides from this module.

test_a_stage_is_one_line_with_its_summary(...)

test_a_stage_within_a_stage_is_a_detail(caplog)

test_a_stage_that_raises_logs_nothing_and_leaves_the_depth(caplog)

test_case_config()

test_the_data_chain_is_a_few_lines_at_info(...)

The contract of INFO: one line per stage (a file or parameter: DEBUG).

test_a_benders_run_counts_its_models_as_details(...)

Otherwise one INFO line for each of tens of subproblems.

test_a_certain_infeasibility_is_an_error()

_short_benders_run(parameters, **options)

A few Benders iterations, for what they log, feasible plan or not.

test_case_parameters(test_case_config)

test_the_file_of_events_is_the_history(pommes_logger, ...)

The same dictionaries: the file holds what a kill would lose.

test_the_file_keeps_the_iterations_of_a_failed_run(...)

test_the_console_shows_the_iterations_as_a_table(...)

test_the_table_repeats_its_header()

test_an_application_reads_one_line_per_iteration(...)

Outside configure_logging, the message stands on its own.

test_a_run_that_raises_says_what_it_recovered_from(...)

test_the_count_of_a_replaced_master_is_kept()

test_a_benders_run_leaves_the_standard_output_alone(...)

At the file descriptors: HiGHS writes from C, past sys.stdout.

test_the_highs_class_comes_back_after_quiet_blocks()

Overlapping blocks, as subproblems on threads make them.

test_quiet_highs_does_not_overrule_the_options()

test_a_quiet_highs_writes_nothing_when_created(through)

HiGHS 1.16 writes its banner from __init__, once a process (#165).

test_the_master_log_goes_to_its_file(pommes_logger, ...)

test_the_report_on_the_master_leaves_the_run_unchanged(...)

test_no_solver_log_unless_asked(pommes_logger)

test_a_solver_log_is_named_after_its_problem(...)

test_no_console_and_no_file_is_silent(pommes_logger, ...)

test_a_failed_solve_leaves_its_log_in_a_file(...)

The robust solve is the one a replay would want to read.

test_a_log_that_cannot_be_opened_costs_the_log_only(...)

test_the_highs_log_can_be_turned_off_again(tmp_path)

Module Contents

pommes.tests.test_logging.raising(error)
pommes.tests.test_logging._small_subproblem()
pommes.tests.test_logging.run_python(code, **environment)

Run code in a fresh interpreter: logging state is process-wide.

pommes.tests.test_logging.pommes_logger()

Give back the pommes logger as configure_logging found it.

pommes.tests.test_logging.test_a_warning_leaves_the_root_logger_to_the_application()

The application’s basicConfig still takes effect after a warning.

A call on the root logger installs a handler, and basicConfig then does nothing, however late the application asks.

pommes.tests.test_logging.test_a_failed_total_is_raised()

calculate_total_costs would stumble on a None further on.

pommes.tests.test_logging.test_import_writes_nothing_and_configures_nothing()
pommes.tests.test_logging.test_a_warning_shows_without_any_configuration()

A NullHandler on pommes would silence it (logging.lastResort).

pommes.tests.test_logging.test_the_environment_variable_turns_the_display_on()
pommes.tests.test_logging.test_configure_logging_goes_to_the_standard_error(pommes_logger, capsys)
pommes.tests.test_logging.test_configure_logging_replaces_the_previous_call(pommes_logger, capsys)
pommes.tests.test_logging.test_configure_logging_stops_the_records_at_pommes(pommes_logger, caplog)

Shown by configure_logging, they must not be shown by the root too.

pommes.tests.test_logging.test_an_unknown_level_is_refused(pommes_logger)
pommes.tests.test_logging.test_the_file_holds_one_json_object_per_record(pommes_logger, tmp_path)
pommes.tests.test_logging.test_the_package_neither_prints_nor_calls_the_root_logger()

Each call of the root logger or to print hides from this module.

pommes.tests.test_logging.test_a_stage_is_one_line_with_its_summary(pommes_logger, capsys)
pommes.tests.test_logging.test_a_stage_within_a_stage_is_a_detail(caplog)
pommes.tests.test_logging.test_a_stage_that_raises_logs_nothing_and_leaves_the_depth(caplog)
pommes.tests.test_logging.test_case_config()
pommes.tests.test_logging.test_the_data_chain_is_a_few_lines_at_info(test_case_config, caplog)

The contract of INFO: one line per stage (a file or parameter: DEBUG).

pommes.tests.test_logging.test_a_benders_run_counts_its_models_as_details(test_case_config, caplog)

Otherwise one INFO line for each of tens of subproblems.

pommes.tests.test_logging.test_a_certain_infeasibility_is_an_error()
pommes.tests.test_logging._short_benders_run(parameters, **options)

A few Benders iterations, for what they log, feasible plan or not.

These tests read the logs and the solver output of a run cut short by max_iter. Whether a feasible plan came up in those iterations depends on the vertices the solver returns (HiGHS 1.16 finds one an iteration later than 1.15, #165), and the run then raises BendersNoIncumbentError after logging all it had to log.

pommes.tests.test_logging.test_case_parameters(test_case_config)
pommes.tests.test_logging.test_the_file_of_events_is_the_history(pommes_logger, test_case_parameters, tmp_path)

The same dictionaries: the file holds what a kill would lose.

pommes.tests.test_logging.test_the_file_keeps_the_iterations_of_a_failed_run(pommes_logger, test_case_parameters, tmp_path)
pommes.tests.test_logging.test_the_console_shows_the_iterations_as_a_table(pommes_logger, test_case_parameters, capsys)
pommes.tests.test_logging.test_the_table_repeats_its_header()
pommes.tests.test_logging.test_an_application_reads_one_line_per_iteration(test_case_parameters, caplog)

Outside configure_logging, the message stands on its own.

pommes.tests.test_logging.test_a_run_that_raises_says_what_it_recovered_from(test_case_parameters, monkeypatch, caplog)
pommes.tests.test_logging.test_the_count_of_a_replaced_master_is_kept()
pommes.tests.test_logging.test_a_benders_run_leaves_the_standard_output_alone(test_case_parameters, capfd)

At the file descriptors: HiGHS writes from C, past sys.stdout.

pommes.tests.test_logging.test_the_highs_class_comes_back_after_quiet_blocks()

Overlapping blocks, as subproblems on threads make them.

pommes.tests.test_logging.test_quiet_highs_does_not_overrule_the_options()
pommes.tests.test_logging.test_a_quiet_highs_writes_nothing_when_created(through)

HiGHS 1.16 writes its banner from __init__, once a process (#165).

In a fresh interpreter, then: one created earlier in the same process would have written it already.

pommes.tests.test_logging.test_the_master_log_goes_to_its_file(pommes_logger, test_case_parameters, tmp_path, capfd, n_jobs)
pommes.tests.test_logging.test_the_report_on_the_master_leaves_the_run_unchanged(pommes_logger, test_case_parameters, capfd)
pommes.tests.test_logging.test_no_solver_log_unless_asked(pommes_logger)
pommes.tests.test_logging.test_a_solver_log_is_named_after_its_problem(pommes_logger, tmp_path)
pommes.tests.test_logging.test_no_console_and_no_file_is_silent(pommes_logger, capsys)
pommes.tests.test_logging.test_a_failed_solve_leaves_its_log_in_a_file(pommes_logger, monkeypatch, tmp_path)

The robust solve is the one a replay would want to read.

pommes.tests.test_logging.test_a_log_that_cannot_be_opened_costs_the_log_only(pommes_logger, monkeypatch, tmp_path, caplog)
pommes.tests.test_logging.test_the_highs_log_can_be_turned_off_again(tmp_path)