Files
pepperplus-ri/test/unit/test_time_block.py
Twirre Meulenbelt 5631a55697 test: convert to pytest
Instead of built-in `unittest`, now use `pytest`. Find versions that work, convert tests.

ref: N25B-168
2025-10-21 13:55:06 +02:00

38 lines
618 B
Python

import time
import mock
from robot_interface.utils.timeblock import TimeBlock
class AnyFloat(object):
def __eq__(self, other):
return isinstance(other, float)
def test_no_limit():
callback = mock.Mock()
with TimeBlock(callback):
pass
callback.assert_called_once_with(AnyFloat())
def test_exceed_limit():
callback = mock.Mock()
with TimeBlock(callback, 0):
time.sleep(0.001)
callback.assert_called_once_with(AnyFloat())
def test_within_limit():
callback = mock.Mock()
with TimeBlock(callback, 5):
pass
callback.assert_not_called()