Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 186fbd8

Browse files
fix(test): set terminal width for cli tests
Force consistent terminal width for tests to avoid wrapping differences between single and multi-worker pytest modes Signed-off-by: Sebastien Fusilier <sebastien.fusilier@gmail.com>
1 parent 061e183 commit 186fbd8

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

‎tests/commands/test_version_command.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import platform
23
import sys
34

@@ -112,10 +113,22 @@ def test_version_use_version_provider(
112113
def test_version_command_shows_description_when_use_help_option(
113114
mocker: MockerFixture, capsys, file_regression
114115
):
115-
testargs = ["cz", "version", "--help"]
116-
mocker.patch.object(sys, "argv", testargs)
117-
with pytest.raises(SystemExit):
118-
cli.main()
119-
120-
out, _ = capsys.readouterr()
121-
file_regression.check(out, extension=".txt")
116+
# Force consistent terminal width for tests to avoid wrapping differences
117+
# between single and multi-worker pytest modes
118+
original_columns = os.environ.get("COLUMNS")
119+
os.environ["COLUMNS"] = "80"
120+
121+
try:
122+
testargs = ["cz", "version", "--help"]
123+
mocker.patch.object(sys, "argv", testargs)
124+
with pytest.raises(SystemExit):
125+
cli.main()
126+
127+
out, _ = capsys.readouterr()
128+
file_regression.check(out, extension=".txt")
129+
finally:
130+
# Restore original COLUMNS
131+
if original_columns is not None:
132+
os.environ["COLUMNS"] = original_columns
133+
else:
134+
os.environ.pop("COLUMNS", None)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /