potiuk commented on code in PR #70103:
URL: https://github.com/apache/airflow/pull/70103#discussion_r3956945221
##########
providers/snowflake/tests/unit/snowflake/operators/test_snowpark_containers.py:
##########
@@ -150,6 +168,32 @@ def test_poll_waits_through_pending_then_done(self,
mock_hook_cls, mock_sleep):
assert op._poll_for_status() == "DONE"
assert mock_sleep.call_count == 2
+ @pytest.mark.parametrize(
+ ("drop_on_completion", "drops"),
+ [(True, True), (False, False)],
+ )
+ @mock.patch("time.sleep")
+ @mock.patch("time.monotonic", side_effect=[0, 0, 20])
Review Comment:
`side_effect=[0, 0, 20]` supplies exactly the three values
`_poll_for_status` consumes today: one for `end_time`, one for the check that
must be under the deadline, one for the check that must be over it. It works,
and the parametrized drop/no-drop split still exercises both cleanup paths.
The fragility is that `mock.patch("time.monotonic", ...)` patches the clock
**process-wide** for the whole test body, not just the call under test.
Anything else that reads the monotonic clock while the patch is active —
`_make_operator`'s `BaseOperator.__init__`, a logging handler, or simply a
fourth call if the loop ever grows one — raises `StopIteration` from somewhere
with no obvious connection to the assertion.
An unbounded counter reads the same and cannot exhaust:
```suggestion
@mock.patch("time.monotonic", side_effect=itertools.count(0, 20))
```
(with `import itertools` at the top). Same three values consumed, same
behaviour, no coupling to the exact call count.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]