Skip to content

Commit 8ac7f94

Browse files
committed
Trying color flag to false for ASCII error
1 parent 98cf20d commit 8ac7f94

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/wristpy/core/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def main(
8484
ActivityMetric.enmo,
8585
"-a",
8686
"--activity-metric",
87-
help="Metric should be used for physical activity categorization."
87+
help="Metric used for physical activity categorization."
8888
"Choose from 'enmo', 'mad', or 'ag_count'.",
8989
case_sensitive=False,
9090
),
@@ -94,7 +94,7 @@ def main(
9494
"--thresholds",
9595
help="Provide three thresholds for light, moderate, and vigorous activity. "
9696
"Exactly three values must be >= 0, given in ascending order,"
97-
" and separated by a space.",
97+
" and separated by a space. (e.g. '-t 0.1 1.0 1.5').",
9898
min=0,
9999
),
100100
nonwear_algorithm: list[NonwearAlgorithms] = typer.Option(

tests/unit/test_cli.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55

66
import pytest
77
import pytest_mock
8-
from typer.testing import CliRunner
8+
from typer import testing
99

1010
from 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

1919
def 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(
4444
def 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(
6767
def 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(
9090
def 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

161161
def 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

175174
def 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(
198198
def 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

Comments
 (0)