amoghrajesh commented on code in PR #77762:
URL: https://github.com/apache/airflow/pull/77762#discussion_r4747972072


##########
AGENTS.md:
##########
@@ -166,6 +166,7 @@ reported as such are described in "What is NOT considered a 
security vulnerabili
 - Use `spec`/`autospec` when mocking.
 - Prefer `@mock.patch` decorators over `with mock.patch(...)` context managers 
for patching. Use `conf_vars` (from `tests_common.test_utils.config`) for 
Airflow config overrides — as a decorator when the value is fixed, as a context 
manager when it varies via `@pytest.mark.parametrize` or is only known at run 
time. In `async def` tests always use it as a context manager inside the body: 
as a decorator it hides the coroutine from pytest-asyncio and the test fails.
 - Use `time_machine` for time-dependent tests. Do not use `datetime.now()`
+- Do not assert on elapsed wall-clock time (`time.monotonic() - start < N`) or 
release threads with `threading.Timer`: both flake on loaded CI runners. 
Synchronise with `threading.Event` or `threading.Barrier` and assert order 
instead, e.g. that an event is still unset when the call returns. Patch time 
functions where the code under test looks them up 
(`mock.patch("pkg.module.time.monotonic")`), never `time.monotonic` or 
`time.sleep` globally, which also changes the clock for boto, moto and other 
libraries.

Review Comment:
   Good catch, and you are right. `pkg.module.time` resolves to the shared time 
module, so that form patches globally. Switched both files to 
`mock.patch("pkg.module.time", autospec=True)` and said the other form is 
global too.



-- 
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]

Reply via email to