Skip to content

Commit e169431

Browse files
tigarmolengau
authored andcommitted
fix(tests): fix a test broken in Python 3.12.8 (#595)
Since 3.12.8, argparse 'choices' are no longer quoted. Ref: python/cpython#11776 --------- Co-authored-by: Alex Lowe <alex.lowe@canonical.com>
1 parent 8b617c8 commit e169431

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/integration/commands/test_init.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""Tests for init command."""
1818
import os
1919
import pathlib
20+
import sys
2021
import textwrap
2122

2223
import pytest
@@ -113,7 +114,12 @@ def test_init_name(app, capsys, monkeypatch, project_dir, expected_file):
113114
@pytest.mark.usefixtures("fake_template_dirs")
114115
def test_init_invalid_profile(app, capsys, monkeypatch):
115116
"""Give a helpful error message for invalid profiles."""
116-
expected_error = "Error: argument --profile: invalid choice: 'bad' (choose from 'other-template', 'simple')"
117+
choices = "other-template, simple"
118+
if sys.version_info < (3, 12, 8):
119+
choices = "'other-template', 'simple'"
120+
expected_error = (
121+
f"Error: argument --profile: invalid choice: 'bad' (choose from {choices})"
122+
)
117123
monkeypatch.setattr("sys.argv", ["testcraft", "init", "--profile", "bad"])
118124

119125
return_code = app.run()

0 commit comments

Comments
 (0)