mirror of
https://github.com/open-mmlab/mmengine.git
synced 2025-06-03 21:54:44 +08:00
* Fix hook * Fix * Fix docs * FIx * Fix * Fix as comment * update * Fix hook * Fix hook * Fix hook * Fix itertimerhook * Fix iter_timer_hook * Fix * Fix * fix logger hook * Fix loggerhook * update cur_dataloader * Fix docstring * Fix docstring * Fix as commet * Fix as commet * Fix as comment * rename is_last_epoch, enhance and add after_val before_val .etc * fix typo in docstring * remove resolved TODO * refactor docstring
30 lines
803 B
Python
30 lines
803 B
Python
# Copyright (c) OpenMMLab. All rights reserved.
|
|
from unittest.mock import Mock
|
|
|
|
from mmengine.hooks import IterTimerHook
|
|
|
|
|
|
class TestIterTimerHook:
|
|
|
|
def test_before_epoch(self):
|
|
Hook = IterTimerHook()
|
|
Runner = Mock()
|
|
Hook._before_epoch(Runner)
|
|
assert isinstance(Hook.t, float)
|
|
|
|
def test_before_iter(self):
|
|
Hook = IterTimerHook()
|
|
Runner = Mock()
|
|
Runner.log_buffer = dict()
|
|
Hook._before_epoch(Runner)
|
|
Hook._before_iter(Runner)
|
|
Runner.message_hub.update_log.assert_called()
|
|
|
|
def test_after_iter(self):
|
|
Hook = IterTimerHook()
|
|
Runner = Mock()
|
|
Runner.log_buffer = dict()
|
|
Hook._before_epoch(Runner)
|
|
Hook._after_iter(Runner)
|
|
Runner.message_hub.update_log.assert_called()
|