Skip to content

Commit 9451810

Browse files
committed
fix: log user warning rather than printing to console
1 parent a91aa59 commit 9451810

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

‎CodeEntropy/entropy/workflow.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,8 @@ def execute(self) -> None:
107107

108108
if self._args.water_entropy and water_groups:
109109
if not nonwater_groups:
110-
console.print(
111-
"Warning: You are running waterEntropy on bulk water, "
112-
"this will be slow!"
110+
logger.warning(
111+
"You are running waterEntropy on bulk water, this will be slow!"
113112
)
114113
self._compute_water_entropy(frame_selection, water_groups)
115114
else:

‎tests/unit/CodeEntropy/entropy/test_workflow.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def test_execute_water_entropy_branch_calls_water_entropy_solver(
127127
patch("CodeEntropy.entropy.workflow.WaterEntropy") as WaterCls,
128128
patch("CodeEntropy.entropy.workflow.LevelDAG") as LevelDAGCls,
129129
patch("CodeEntropy.entropy.workflow.EntropyGraph") as GraphCls,
130-
patch("CodeEntropy.entropy.workflow.console") as console,
130+
patch("CodeEntropy.entropy.workflow.logger") as logger,
131131
):
132132
water_instance = WaterCls.return_value
133133
water_instance.calculate_and_log = MagicMock()
@@ -139,10 +139,8 @@ def test_execute_water_entropy_branch_calls_water_entropy_solver(
139139

140140
water_instance.calculate_and_log.assert_called_once()
141141
_, kwargs = water_instance.calculate_and_log.call_args
142-
warning = call(
143-
"Warning: You are running waterEntropy on bulk water, this will be slow!"
144-
)
145-
assert (warning in console.print.call_args_list) is expect_warning
142+
warning = call("You are running waterEntropy on bulk water, this will be slow!")
143+
assert (warning in logger.warning.call_args_list) is expect_warning
146144
assert kwargs["universe"] is universe
147145
assert kwargs["start"] == 0
148146
assert kwargs["end"] == 5

0 commit comments

Comments
 (0)