Skip to content

Commit 5c1a274

Browse files
committed
Add GitHub Actions testing on Python 3.15-dev
Also: - Fix test failure on versions of Python before 3.14
1 parent 2ff6640 commit 5c1a274

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [ubuntu-latest, macos-latest, windows-latest]
15-
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"]
15+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.14t", "3.15-dev"]
1616
fail-fast: false
1717

1818
runs-on: ${{ matrix.os }}

tests/test_argparse_custom.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Unit/functional testing for argparse customizations in cmd2"""
22

33
import argparse
4+
import sys
45

56
import pytest
67

@@ -12,6 +13,8 @@
1213
)
1314
from cmd2.argparse_custom import (
1415
ChoicesCallable,
16+
Cmd2HelpFormatter,
17+
Cmd2RichArgparseConsole,
1518
generate_range_error,
1619
)
1720

@@ -355,28 +358,29 @@ def test_completion_items_as_choices(capsys) -> None:
355358
assert 'invalid choice: 3 (choose from 1, 2)' in err
356359

357360

358-
def test_formatter_coverage(mocker) -> None:
359-
import sys
360-
361-
from cmd2.argparse_custom import (
362-
Cmd2HelpFormatter,
363-
Cmd2RichArgparseConsole,
364-
)
365-
366-
# Line 1031: self._console = console (inside console.setter)
361+
def test_formatter_console() -> None:
362+
# self._console = console (inside console.setter)
367363
formatter = Cmd2HelpFormatter(prog='test')
368364
new_console = Cmd2RichArgparseConsole()
369365
formatter.console = new_console
370366
assert formatter._console is new_console
371367

372-
# Line 1041: return (inside _set_color if sys.version_info < (3, 14))
368+
369+
@pytest.mark.skipif(
370+
sys.version_info < (3, 14),
371+
reason="Argparse didn't support color until Python 3.14",
372+
)
373+
def test_formatter_set_color(mocker) -> None:
374+
formatter = Cmd2HelpFormatter(prog='test')
375+
376+
# return (inside _set_color if sys.version_info < (3, 14))
373377
mocker.patch('cmd2.argparse_custom.sys.version_info', (3, 13, 0))
374378
# This should return early without calling super()._set_color
375379
mock_set_color = mocker.patch('rich_argparse.RichHelpFormatter._set_color')
376380
formatter._set_color(True)
377381
mock_set_color.assert_not_called()
378382

379-
# Line 1045 and 1047: except TypeError and super()._set_color(color)
383+
# except TypeError and super()._set_color(color)
380384
mocker.patch('cmd2.argparse_custom.sys.version_info', (3, 15, 0))
381385

382386
# Reset mock and make it raise TypeError when called with kwargs

0 commit comments

Comments
 (0)