File: py314-tests.patch

package info (click to toggle)
python-argh 0.31.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 400 kB
  • sloc: python: 3,231; makefile: 4
file content (92 lines) | stat: -rw-r--r-- 3,048 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
From: Andy Mikhaylenko <neithere@gmail.com>
Date: Sun, 1 Jun 2025 21:28:53 +0200
Subject: fix(test): tests were broken under Python 3.14.0b2 (fixes #239)

Origin: backport, https://github.com/neithere/argh/pull/240/changes/699568ad674c5ea26d361202c386a8a8a82ec8ad
Bug: https://github.com/neithere/argh/issues/239
Bug-Debian: https://bugs.debian.org/1123190
Last-Update: 2026-02-03
---
 tests/base.py             |  7 -------
 tests/test_integration.py | 20 +++++++++++++-------
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/tests/base.py b/tests/base.py
index 7710443..a031f25 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -4,8 +4,6 @@ Common stuff for tests
 """
 
 import io
-import os
-import sys
 from collections import namedtuple
 
 from argh import ArghParser
@@ -72,8 +70,3 @@ def run(parser, command_string, kwargs=None, exit=False):
             raise AssertionError("Did not exit")
         return result.exit_code
     return result
-
-
-def get_usage_string(definitions="{cmd} ..."):
-    prog = os.path.basename(sys.argv[0])
-    return "usage: " + prog + " [-h] " + definitions + "\n\n"
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 8839265..6fc8a17 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -17,7 +17,7 @@ from argh.exceptions import AssemblingError
 from argh.utils import unindent
 
 from .base import CmdResult as R
-from .base import DebugArghParser, get_usage_string, run
+from .base import DebugArghParser, run
 
 if sys.version_info < (3, 10):
     HELP_OPTIONS_LABEL = "optional arguments"
@@ -796,11 +796,17 @@ def test_help_formatting_is_preserved():
     parser = DebugArghParser()
     parser.set_default_command(func)
 
-    assert unindent(func.__doc__) in parser.format_help()
+    docstring = func.__doc__
+    assert docstring
+    assert unindent(docstring) in parser.format_help()
 
 
 def test_prog(capsys: pytest.CaptureFixture[str]):
-    "Program name propagates from sys.argv[0]"
+    """
+    Program name propagates to the usage string.
+    It's not just sys.argv[0], the logic is a bit more complicated in argparse,
+    so we just reuse whatever it has produced.
+    """
 
     def cmd(*, foo=1):
         return foo
@@ -808,10 +814,12 @@ def test_prog(capsys: pytest.CaptureFixture[str]):
     parser = DebugArghParser()
     parser.add_commands([cmd])
 
-    usage = get_usage_string()
+    usage = f"usage: {parser.prog} [-h]"
 
-    assert run(parser, "-h", exit=True) == 0
+    exit_code = run(parser, "-h", exit=True)
     captured = capsys.readouterr()
+
+    assert exit_code == 0
     assert captured.out.startswith(usage)
 
 
@@ -822,8 +830,6 @@ def test_unknown_args():
     parser = DebugArghParser()
     parser.set_default_command(cmd)
 
-    get_usage_string("[-f FOO]")
-
     assert run(parser, "--foo 1") == R(out="1\n", err="")
     assert run(parser, "--bar 1", exit=True) == "unrecognized arguments: --bar 1"
     assert run(parser, "--bar 1", exit=False, kwargs={"skip_unknown_args": True}) == R(