[Fix] Only test Timer in Linux platform (#823)

This commit is contained in:
Mashiro 2022-12-13 19:11:09 +08:00 committed by GitHub
parent 8026b20e68
commit 95c71c82d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
# Copyright (c) OpenMMLab. All rights reserved.
import platform
import time
import pytest
@ -6,6 +7,8 @@ import pytest
import mmengine
@pytest.mark.skipif(
platform.system() != 'Linux', reason='Only test `Timer` in linux!')
def test_timer_init():
timer = mmengine.Timer(start=False)
assert not timer.is_running
@ -15,6 +18,8 @@ def test_timer_init():
assert timer.is_running
@pytest.mark.skipif(
platform.system() != 'Linux', reason='Only test `Timer` in linux!')
def test_timer_run():
timer = mmengine.Timer()
time.sleep(1)
@ -31,6 +36,8 @@ def test_timer_run():
timer.since_last_check()
@pytest.mark.skipif(
platform.system() != 'Linux', reason='Only test `Timer` in linux!')
def test_timer_context(capsys):
with mmengine.Timer():
time.sleep(1)