mirror of
https://github.com/markqvist/rnsh.git
synced 2025-01-20 19:21:34 -05:00
Test improvements
This commit is contained in:
parent
2b3089ddd5
commit
1f31307307
@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import time
|
||||
import types
|
||||
import typing
|
||||
import tempfile
|
||||
@ -147,4 +148,16 @@ def test_config_and_cleanup():
|
||||
assert filedata.index("acehoss test config") > 0
|
||||
with pytest.raises(ValueError):
|
||||
filedata.index("22222")
|
||||
assert not os.path.exists(os.path.join(td, "config"))
|
||||
assert not os.path.exists(os.path.join(td, "config"))
|
||||
|
||||
|
||||
def wait_for_condition(condition: callable, timeout: float):
|
||||
tm = time.time() + timeout
|
||||
while tm > time.time() and not condition():
|
||||
time.sleep(0.01)
|
||||
|
||||
|
||||
async def wait_for_condition_async(condition: callable, timeout: float):
|
||||
tm = time.time() + timeout
|
||||
while tm > time.time() and not condition():
|
||||
await asyncio.sleep(0.01)
|
@ -8,7 +8,7 @@ import multiprocessing.pool
|
||||
logging.getLogger().setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo():
|
||||
"""
|
||||
@ -30,7 +30,7 @@ async def test_echo():
|
||||
assert not state.process.running
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo_live():
|
||||
"""
|
||||
@ -52,7 +52,7 @@ async def test_echo_live():
|
||||
assert not state.process.running
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo_live_pipe_in():
|
||||
"""
|
||||
@ -74,7 +74,7 @@ async def test_echo_live_pipe_in():
|
||||
assert not state.process.running
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo_live_pipe_out():
|
||||
"""
|
||||
@ -99,7 +99,7 @@ async def test_echo_live_pipe_out():
|
||||
assert not state.process.running
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo_live_pipe_err():
|
||||
"""
|
||||
@ -121,7 +121,7 @@ async def test_echo_live_pipe_err():
|
||||
assert not state.process.running
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo_live_pipe_out_err():
|
||||
"""
|
||||
@ -147,7 +147,7 @@ async def test_echo_live_pipe_out_err():
|
||||
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_echo_live_pipe_all():
|
||||
"""
|
||||
@ -170,7 +170,7 @@ async def test_echo_live_pipe_all():
|
||||
assert not state.process.running
|
||||
|
||||
|
||||
# @pytest.mark.skip_ci
|
||||
@pytest.mark.skip_ci
|
||||
@pytest.mark.asyncio
|
||||
async def test_double_echo_live():
|
||||
"""
|
||||
|
@ -62,7 +62,8 @@ async def get_id_and_dest(td: str) -> tuple[str, str]:
|
||||
await asyncio.sleep(0.1)
|
||||
assert wrapper.process.running
|
||||
# wait for process to start up
|
||||
await asyncio.sleep(3)
|
||||
await tests.helpers.wait_for_condition_async(lambda: not wrapper.process.running, 5)
|
||||
assert not wrapper.process.running
|
||||
# read the output
|
||||
text = wrapper.read().decode("utf-8").replace("\r", "").replace("\n", "")
|
||||
assert text.index("Identity") is not None
|
||||
@ -73,7 +74,6 @@ async def get_id_and_dest(td: str) -> tuple[str, str]:
|
||||
dh = match.group(2)
|
||||
assert len(dh) == 32
|
||||
await asyncio.sleep(0.1)
|
||||
assert not wrapper.process.running
|
||||
return ih, dh
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user