|
| 1 | +import re |
1 | 2 | from unittest.mock import patch |
2 | 3 |
|
3 | 4 | from typer.testing import CliRunner |
4 | 5 |
|
5 | 6 | from comfy_cli.command.custom_nodes.command import app |
6 | 7 |
|
7 | | -runner = CliRunner() |
| 8 | +runner = CliRunner(mix_stderr=False) |
| 9 | + |
| 10 | + |
| 11 | +def strip_ansi(text): |
| 12 | + """Remove ANSI escape sequences from text.""" |
| 13 | + ansi_escape = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') |
| 14 | + return ansi_escape.sub('', text) |
8 | 15 |
|
9 | 16 |
|
10 | 17 | def test_install_no_deps_option_exists(): |
11 | 18 | """Test that the --no-deps option appears in the help.""" |
12 | 19 | result = runner.invoke(app, ["install", "--help"]) |
13 | 20 | assert result.exit_code == 0 |
14 | | - assert "--no-deps" in result.stdout |
15 | | - assert "Skip dependency installation" in result.stdout |
| 21 | + clean_output = strip_ansi(result.stdout) |
| 22 | + assert "--no-deps" in clean_output |
| 23 | + assert "Skip dependency installation" in clean_output |
16 | 24 |
|
17 | 25 |
|
18 | 26 | def test_install_fast_deps_and_no_deps_mutually_exclusive(): |
19 | 27 | """Test that --fast-deps and --no-deps cannot be used together.""" |
20 | 28 | result = runner.invoke(app, ["install", "test-node", "--fast-deps", "--no-deps"]) |
21 | 29 | assert result.exit_code != 0 |
22 | | - assert "Cannot use --fast-deps and --no-deps together" in result.stdout |
| 30 | + # Check both stdout and stderr for the error message |
| 31 | + output = result.stdout + result.stderr |
| 32 | + assert "Cannot use --fast-deps and --no-deps together" in output |
23 | 33 |
|
24 | 34 |
|
25 | 35 | def test_install_no_deps_alone_works(): |
|
0 commit comments