55
66import pytest
77import pytest_mock
8- from typer . testing import CliRunner
8+ from typer import testing
99
1010from wristpy .core import cli , orchestrator
1111
1212
1313@pytest .fixture
14- def create_typer_cli_runner () -> CliRunner :
14+ def create_typer_cli_runner () -> testing . CliRunner :
1515 """Create a Typer CLI runner."""
16- return CliRunner ()
16+ return testing . CliRunner ()
1717
1818
1919def test_main_default (
2020 mocker : pytest_mock .MockerFixture ,
2121 sample_data_gt3x : pathlib .Path ,
22- create_typer_cli_runner : CliRunner ,
22+ create_typer_cli_runner : testing . CliRunner ,
2323) -> None :
2424 """Test cli with only necessary arguments."""
2525 mock_run = mocker .patch .object (orchestrator , "run" )
@@ -44,7 +44,7 @@ def test_main_default(
4444def test_main_enmo_default (
4545 mocker : pytest_mock .MockerFixture ,
4646 sample_data_gt3x : pathlib .Path ,
47- create_typer_cli_runner : CliRunner ,
47+ create_typer_cli_runner : testing . CliRunner ,
4848) -> None :
4949 """Test that correct enmo default thresholds are pulled."""
5050 mock_run = mocker .patch .object (orchestrator , "_run_file" )
@@ -67,7 +67,7 @@ def test_main_enmo_default(
6767def test_main_mad_default (
6868 mocker : pytest_mock .MockerFixture ,
6969 sample_data_gt3x : pathlib .Path ,
70- create_typer_cli_runner : CliRunner ,
70+ create_typer_cli_runner : testing . CliRunner ,
7171) -> None :
7272 """Test that correct mad default thresholds are pulled."""
7373 mock_run = mocker .patch .object (orchestrator , "_run_file" )
@@ -90,7 +90,7 @@ def test_main_mad_default(
9090def test_main_agcount_default (
9191 mocker : pytest_mock .MockerFixture ,
9292 sample_data_gt3x : pathlib .Path ,
93- create_typer_cli_runner : CliRunner ,
93+ create_typer_cli_runner : testing . CliRunner ,
9494) -> None :
9595 """Test that correct ag_count default thresholds are pulled."""
9696 mock_run = mocker .patch .object (orchestrator , "_run_file" )
@@ -114,7 +114,7 @@ def test_main_with_options(
114114 mocker : pytest_mock .MockerFixture ,
115115 sample_data_gt3x : pathlib .Path ,
116116 tmp_path : pathlib .Path ,
117- create_typer_cli_runner : CliRunner ,
117+ create_typer_cli_runner : testing . CliRunner ,
118118) -> None :
119119 """Test cli with optional arguments."""
120120 test_output = tmp_path / "test.csv"
@@ -160,31 +160,31 @@ def test_main_with_options(
160160
161161def test_main_with_bad_thresholds (
162162 sample_data_gt3x : pathlib .Path ,
163- create_typer_cli_runner : CliRunner ,
163+ create_typer_cli_runner : testing . CliRunner ,
164164) -> None :
165165 """Test cli with bad thresholds."""
166166 result = create_typer_cli_runner .invoke (
167- cli .app , [str (sample_data_gt3x ), "-t" , "3.0" ]
167+ cli .app , [str (sample_data_gt3x ), "-t" , "3.0" ], color = False
168168 )
169169
170170 assert result .exit_code != 0
171- # partial matching due to ANSI escape sequences in Github Actions
172- assert "requires 3 arguments." in result .output
171+ assert "Option '-t' requires 3 arguments." in result .output
173172
174173
175174def test_main_with_bad_epoch (
176175 sample_data_gt3x : pathlib .Path ,
177- create_typer_cli_runner : CliRunner ,
176+ create_typer_cli_runner : testing . CliRunner ,
178177) -> None :
179178 """Test cli with invalid epoch length."""
180179 result = create_typer_cli_runner .invoke (
181- cli .app , [str (sample_data_gt3x ), "-e" , "-5" ]
180+ cli .app , [str (sample_data_gt3x ), "-e" , "-5" ], color = False
182181 )
183182
184183 assert result .exit_code != 0
185- # partial matching due to ANSI escape sequences in Github Actions
186- assert "Invalid value for" in result .output
187- assert "is not in the range x>=1." in result .output
184+ assert (
185+ "Invalid value for '-e' / '--epoch-length': -5 is not in the range x>=1."
186+ in result .output
187+ )
188188
189189
190190@pytest .mark .parametrize (
@@ -198,7 +198,7 @@ def test_main_with_bad_epoch(
198198def test_main_verbosity (
199199 mocker : pytest_mock .MockerFixture ,
200200 sample_data_gt3x : pathlib .Path ,
201- create_typer_cli_runner : CliRunner ,
201+ create_typer_cli_runner : testing . CliRunner ,
202202 verbosity : str ,
203203 expected_log_level : int ,
204204) -> None :
0 commit comments