Skip to content

Tests🔗

berhoel.helper.tests.test_berhoel_helper 🔗

Tests for berhoel.helper.

Functions:

Functions🔗

berhoel.helper.tests.test_berhoel_helper.test_count_with_message_1 🔗

test_count_with_message_1(capsys)

Test counter with life message.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_count_with_message_1(capsys):
    """Test counter with life message."""
    count = helper.count_with_msg()
    for i, j in enumerate(count):
        res = capsys.readouterr()
        assert i == j
        assert res.out == f"loop {i + 1} \r"
        if i > 5:
            break

berhoel.helper.tests.test_berhoel_helper.test_count_with_message_2 🔗

test_count_with_message_2(capsys)

Test counter with life message.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_count_with_message_2(capsys):
    """Test counter with life message."""
    count = helper.count_with_msg(start=10)
    for i, j in enumerate(count):
        res = capsys.readouterr()
        assert i + 10 == j
        assert res.out == f"loop {i + 1} \r"
        if i > 5:
            break

berhoel.helper.tests.test_berhoel_helper.test_count_with_message_3 🔗

test_count_with_message_3(capsys)

Test counter with life message.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_count_with_message_3(capsys):
    """Test counter with life message."""
    count = helper.count_with_msg(msg="msg")
    for i, j in enumerate(count):
        res = capsys.readouterr()
        assert i == j
        assert res.out == f"msg {i + 1} \r"
        if i > 5:
            break

berhoel.helper.tests.test_berhoel_helper.test_count_with_message_4 🔗

test_count_with_message_4(capsys)

Test counter with life message.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_count_with_message_4(capsys):
    """Test counter with life message."""
    count = helper.count_with_msg("alt", 5)
    for i, j in enumerate(count):
        res = capsys.readouterr()
        assert i + 5 == j
        assert res.out == f"alt {i + 1} \r"
        if i > 5:
            break

berhoel.helper.tests.test_berhoel_helper.test_process_msg_context 🔗

test_process_msg_context(capsys)

Test process context.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_process_msg_context(capsys):
    """Test process context."""
    with helper.process_msg_context("do something"):
        res = capsys.readouterr()
        assert res.out == "do something...\r"
    res = capsys.readouterr()
    assert res.out == "do something...done\n"

berhoel.helper.tests.test_berhoel_helper.test_swirl 🔗

test_swirl(capsys)

Test swirler.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_swirl(capsys):
    """Test swirler."""
    swirl = helper.swirl()
    for expected in r"\|/-\|":
        next(swirl)
        res = capsys.readouterr()
        assert res.out == f"{expected}\r"

berhoel.helper.tests.test_berhoel_helper.test_swirl_dots 🔗

test_swirl_dots(capsys)

Test swirler with (braille) dots.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_swirl_dots(capsys):
    """Test swirler with (braille) dots."""
    swirl = helper.swirl(helper.SwirlSelect.DOTS)
    for expected in "⠇⡆⣄⣠⢰⠸⠙⠋":
        next(swirl)
        res = capsys.readouterr()
        assert res.out == f"{expected}\r"

berhoel.helper.tests.test_berhoel_helper.test_timed_process_msg_context_1 🔗

test_timed_process_msg_context_1(capsys)

Test timed process context.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_timed_process_msg_context_1(capsys):
    """Test timed process context."""
    with helper.timed_process_msg_context("do something"):
        res = capsys.readouterr()
        time.sleep(1)
        assert res.out == "do something...\r"
    res = capsys.readouterr()
    assert res.out == "do something...done (0:00:01)\n"

berhoel.helper.tests.test_berhoel_helper.test_timed_process_msg_context_2 🔗

test_timed_process_msg_context_2(capsys)

Test timed process context.

Source code in src/berhoel/helper/tests/test_berhoel_helper.py
def test_timed_process_msg_context_2(capsys):
    """Test timed process context."""
    with helper.timed_process_msg_context("do something", lambda t: f"{int(t):d}s"):
        res = capsys.readouterr()
        time.sleep(1)
        assert res.out == "do something...\r"
    res = capsys.readouterr()
    assert res.out == "do something...done (1s)\n"

berhoel.helper.tests.test_check_args 🔗

Tests for berhoel.helper.check_args.

Classes🔗

Functions🔗

berhoel.helper.tests.test_machar 🔗

Testing berhoel.helper.machar.