diff --git a/tests/test_record.py b/tests/test_record.py index 80c5de9..cc16d24 100644 --- a/tests/test_record.py +++ b/tests/test_record.py @@ -1,5 +1,4 @@ import anyio -import asyncclick as click import pytest from asyncclick.testing import CliRunner @@ -13,19 +12,14 @@ async def test_record_start(): assert result.exit_code == 0 active = "Recording is currently active." in result.output + result = await runner.invoke(cli, ["record", "start"]) if not active: - result = await runner.invoke(cli, ["record", "start"]) assert result.exit_code == 0 assert "Recording started" in result.output - await anyio.sleep(1) # Allow some time for the recording to start + await anyio.sleep(0.2) # Allow some time for the recording to start else: - with pytest.raises(ExceptionGroup) as exc_info: - result = await runner.invoke( - cli, ["record", "start"], catch_exceptions=False - ) - assert exc_info.group_contains( - click.Abort, match="Recording is already active." - ) + assert result.exit_code != 0 + assert "Recording is already active." in result.output @pytest.mark.anyio @@ -35,16 +29,11 @@ async def test_record_stop(): assert result.exit_code == 0 active = "Recording is currently active." in result.output + result = await runner.invoke(cli, ["record", "stop"]) if active: - result = await runner.invoke(cli, ["record", "stop"]) assert result.exit_code == 0 assert "Recording stopped" in result.output - await anyio.sleep(1) # Allow some time for the recording to stop + await anyio.sleep(0.2) # Allow some time for the recording to stop else: - with pytest.raises(ExceptionGroup) as exc_info: - result = await runner.invoke( - cli, ["record", "stop"], catch_exceptions=False - ) - assert exc_info.group_contains( - click.Abort, match="Recording is already inactive." - ) + assert result.exit_code != 0 + assert "Recording is already inactive." in result.output diff --git a/tests/test_replaybuffer.py b/tests/test_replaybuffer.py index 3123e78..3fe589c 100644 --- a/tests/test_replaybuffer.py +++ b/tests/test_replaybuffer.py @@ -1,5 +1,4 @@ import anyio -import asyncclick as click import pytest from asyncclick.testing import CliRunner @@ -13,19 +12,14 @@ async def test_replaybuffer_start(): assert result.exit_code == 0 active = "Replay buffer is currently active." in result.output + result = await runner.invoke(cli, ["replaybuffer", "start"]) if not active: - result = await runner.invoke(cli, ["replaybuffer", "start"]) assert result.exit_code == 0 assert "Replay buffer started" in result.output - await anyio.sleep(1) + await anyio.sleep(0.2) # Allow some time for the replay buffer to start else: - with pytest.raises(ExceptionGroup) as exc_info: - result = await runner.invoke( - cli, ["replaybuffer", "start"], catch_exceptions=False - ) - assert exc_info.group_contains( - click.Abort, match="Replay buffer is already active." - ) + assert result.exit_code != 0 + assert "Replay buffer is already active." in result.output @pytest.mark.anyio @@ -35,16 +29,11 @@ async def test_replaybuffer_stop(): assert result.exit_code == 0 active = "Replay buffer is currently active." in result.output + result = await runner.invoke(cli, ["replaybuffer", "stop"]) if active: - result = await runner.invoke(cli, ["replaybuffer", "stop"]) assert result.exit_code == 0 assert "Replay buffer stopped" in result.output - await anyio.sleep(1) + await anyio.sleep(0.2) # Allow some time for the replay buffer to stop else: - with pytest.raises(ExceptionGroup) as exc_info: - result = await runner.invoke( - cli, ["replaybuffer", "stop"], catch_exceptions=False - ) - assert exc_info.group_contains( - click.Abort, match="Replay buffer is already inactive." - ) + assert result.exit_code != 0 + assert "Replay buffer is already inactive." in result.output diff --git a/tests/test_stream.py b/tests/test_stream.py index 9093f2e..1513daa 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -1,5 +1,4 @@ import anyio -import asyncclick as click import pytest from asyncclick.testing import CliRunner @@ -13,17 +12,14 @@ async def test_stream_start(): assert result.exit_code == 0 active = "Stream is currently active." in result.output + result = await runner.invoke(cli, ["stream", "start"]) if not active: - result = await runner.invoke(cli, ["stream", "start"]) assert result.exit_code == 0 assert "Stream started" in result.output - await anyio.sleep(1) # Allow some time for the stream to start + await anyio.sleep(0.2) # Allow some time for the stream to start else: - with pytest.raises(ExceptionGroup) as exc_info: - result = await runner.invoke( - cli, ["stream", "start"], catch_exceptions=False - ) - assert exc_info.group_contains(click.Abort, match="Stream is already active.") + assert result.exit_code != 0 + assert "Stream is already active." in result.output @pytest.mark.anyio @@ -33,14 +29,11 @@ async def test_stream_stop(): assert result.exit_code == 0 active = "Stream is currently active." in result.output + result = await runner.invoke(cli, ["stream", "stop"]) if active: - result = await runner.invoke(cli, ["stream", "stop"]) assert result.exit_code == 0 assert "Stream stopped" in result.output - await anyio.sleep(1) # Allow some time for the stream to stop + await anyio.sleep(0.2) # Allow some time for the stream to stop else: - with pytest.raises(ExceptionGroup) as exc_info: - result = await runner.invoke( - cli, ["stream", "stop"], catch_exceptions=False - ) - assert exc_info.group_contains(click.Abort, match="Stream is already inactive.") + assert result.exit_code != 0 + assert "Stream is already inactive." in result.output