Skip to content

Commit

Permalink
new test
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Aug 27, 2024
1 parent dce8a5e commit 42aa153
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/units/tokens/abstract/test_coroutine_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import io
import sys
from contextlib import redirect_stdout

import pytest

from cantok import SimpleToken, TimeoutToken, ConditionToken, CounterToken


@pytest.mark.parametrize(
['create_value', 'expected_string'],
[
(lambda: SimpleToken(cancelled=True).wait(), ''),
(lambda: TimeoutToken(0.0001).wait(), ''),
(lambda: ConditionToken(lambda: True).wait(), ''),
(lambda: CounterToken(0).wait(), ''),
(lambda: 1, '1\n'),
(lambda: 'kek', f'{repr('kek')}\n'),
],
)
def test_displayhook_printing_coroutine_wrappers_and_other_objects(create_value, expected_string):
buffer = io.StringIO()
with redirect_stdout(buffer):
sys.displayhook(create_value())

output = buffer.getvalue()

assert output == expected_string

0 comments on commit 42aa153

Please sign in to comment.