Skip to content

Commit e6f430b

Browse files
committed
Reactivate windows color tests
1 parent 4957126 commit e6f430b

File tree

6 files changed

+18
-41
lines changed

6 files changed

+18
-41
lines changed

tests/test_cli.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import pytest
2727
from boltons.strutils import strip_ansi
2828
from click_extra.tabulate import output_formats
29-
from extra_platforms import is_windows
3029

3130
from meta_package_manager import __version__
3231
from meta_package_manager.pool import pool
@@ -147,14 +146,12 @@ def test_executable_module(self):
147146
capture_output=True,
148147
encoding="utf-8",
149148
)
150-
151149
assert process.returncode == 0
152150
assert not process.stderr
153-
154-
expected_output = f"\x1b[97mmpm\x1b[0m, version \x1b[32m{__version__}\x1b[0m\n"
155-
if is_windows():
156-
expected_output = strip_ansi(expected_output)
157-
assert process.stdout == expected_output
151+
assert (
152+
process.stdout
153+
== f"\x1b[97mmpm\x1b[0m, version \x1b[32m{__version__}\x1b[0m\n"
154+
)
158155

159156
def test_timeout(self, invoke):
160157
"""Check that the CLI exits with an error when a timeout is reached."""

tests/test_cli_backup.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
from __future__ import annotations
1919

2020
import pytest
21-
from boltons.strutils import strip_ansi
22-
from extra_platforms import is_windows
2321

2422
from meta_package_manager.base import Operations
2523

@@ -69,10 +67,9 @@ def test_single_manager_file_output(self, manager_id, invoke, subcmd):
6967
assert "mpm-packages.toml" in result.stderr
7068
if result.exit_code == 2:
7169
assert not result.stdout
72-
expected_error = "\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
73-
if is_windows():
74-
expected_error = strip_ansi(expected_error)
75-
assert result.stderr.endswith(expected_error)
70+
assert result.stderr.endswith(
71+
"\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
72+
)
7673
else:
7774
assert result.exit_code == 0
7875
self.check_manager_selection(result, {manager_id})

tests/test_cli_install_remove.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import re
2020

2121
import pytest
22-
from boltons.strutils import strip_ansi
23-
from extra_platforms import is_windows
2422

2523
from meta_package_manager.pool import pool
2624

@@ -114,12 +112,9 @@ def test_single_manager_install_and_remove(self, invoke, manager_id, package_id)
114112

115113
if result.exit_code == 2:
116114
assert not result.stdout
117-
expected_error = (
115+
assert result.stderr.endswith(
118116
"\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
119117
)
120-
if is_windows():
121-
expected_error = strip_ansi(expected_error)
122-
assert result.stderr.endswith(expected_error)
123118
else:
124119
assert result.exit_code == 0
125120
self.check_manager_selection(

tests/test_cli_restore.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from __future__ import annotations
1818

1919
import pytest
20-
from boltons.strutils import strip_ansi
21-
from extra_platforms import is_windows
2220

2321
from meta_package_manager.pool import pool
2422

@@ -90,10 +88,9 @@ def test_single_manager(self, invoke, create_config, manager_id):
9088

9189
if result.exit_code == 2:
9290
assert not result.stdout
93-
expected_error = "\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
94-
if is_windows():
95-
expected_error = strip_ansi(expected_error)
96-
assert result.stderr.endswith(expected_error)
91+
assert result.stderr.endswith(
92+
"\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
93+
)
9794
else:
9895
assert result.exit_code == 0
9996
self.check_manager_selection(result, {manager_id})

tests/test_cli_search.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import pytest
2626
from boltons.iterutils import same
27-
from extra_platforms.pytest import skip_windows, unless_macos
27+
from extra_platforms.pytest import unless_macos
2828

2929
from meta_package_manager.base import Operations, Package
3030
from meta_package_manager.pool import pool
@@ -185,11 +185,6 @@ def test_extended_search_multiple_results(self, invoke, query):
185185
# We should find lots of results for this package search.
186186
assert int(msg_match.groups()[0]) >= 20
187187

188-
# XXX Colorama, a dependency of Click, is supposed to transform ANSI codes into
189-
# Windows-specific directives but doesn't. Maybe because the running environment is
190-
# not considered as a terminal. We need to investigate this further and report
191-
# issues to either Click or Colorama.
192-
@skip_windows
193188
def test_search_highlight(self, invoke):
194189
"""We search on cargo as it is available on all platforms.
195190

tests/test_cli_upgrade.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import re
2020

2121
import pytest
22-
from boltons.strutils import strip_ansi
23-
from extra_platforms import is_windows
2422

2523
from meta_package_manager.base import Operations
2624

@@ -79,10 +77,9 @@ def test_single_manager_dry_run_upgrade_all(self, invoke, manager_id, all_option
7977
assert "assume -A/--all option" in result.stderr
8078
if result.exit_code == 2:
8179
assert not result.stdout
82-
expected_error = "\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
83-
if is_windows():
84-
expected_error = strip_ansi(expected_error)
85-
assert result.stderr.endswith(expected_error)
80+
assert result.stderr.endswith(
81+
"\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
82+
)
8683
else:
8784
assert result.exit_code == 0
8885
self.check_manager_selection(result, {manager_id})
@@ -96,10 +93,9 @@ def test_single_manager_upgrade_all(self, invoke, manager_id, all_option):
9693
assert "assume -A/--all option" in result.stderr
9794
if result.exit_code == 2:
9895
assert not result.stdout
99-
expected_error = "\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
100-
if is_windows():
101-
expected_error = strip_ansi(expected_error)
102-
assert result.stderr.endswith(expected_error)
96+
assert result.stderr.endswith(
97+
"\x1b[31m\x1b[1mcritical\x1b[0m: No manager selected.\n"
98+
)
10399
else:
104100
assert result.exit_code == 0
105101
self.check_manager_selection(result, {manager_id})

0 commit comments

Comments
 (0)