at 25.11-pre 5.7 kB view raw
1From c6a974211f1a13d492bb807ff6d07cefcc948a87 Mon Sep 17 00:00:00 2001 2From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> 3Date: Fri, 12 Jul 2024 08:15:40 +0200 4Subject: [PATCH 1/2] update test expectations for Python 3.13 5 6Python 3.13 no longer repeats the placeholder for options with multiple 7aliases in the help message. For example, rather than: 8 9 -c CONFIG_FILE, --config CONFIG_FILE 10 11it now outputs: 12 13 -c, --config CONFIG_FILE 14 15Update the regular expressions to account for both possibilities. 16 17Fixes #294 18--- 19 tests/test_configargparse.py | 24 ++++++++++++------------ 20 1 file changed, 12 insertions(+), 12 deletions(-) 21 22diff --git a/tests/test_configargparse.py b/tests/test_configargparse.py 23index 288e082..e325afd 100644 24--- a/tests/test_configargparse.py 25+++ b/tests/test_configargparse.py 26@@ -271,9 +271,9 @@ def testBasicCase2(self, use_groups=False): 27 ' -h, --help \\s+ show this help message and exit\n' 28 ' --genome GENOME \\s+ Path to genome file\n' 29 ' -v\n' 30- ' -g MY_CFG_FILE, --my-cfg-file MY_CFG_FILE\n' 31- ' -d DBSNP, --dbsnp DBSNP\\s+\\[env var: DBSNP_PATH\\]\n' 32- ' -f FRMT, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n\n'%OPTIONAL_ARGS_STRING + 33+ ' -g( MY_CFG_FILE)?, --my-cfg-file MY_CFG_FILE\n' 34+ ' -d( DBSNP)?, --dbsnp DBSNP\\s+\\[env var: DBSNP_PATH\\]\n' 35+ ' -f( FRMT)?, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n\n'%OPTIONAL_ARGS_STRING + 36 7*r'(.+\s*)') 37 else: 38 self.assertRegex(self.format_help(), 39@@ -286,10 +286,10 @@ def testBasicCase2(self, use_groups=False): 40 'g1:\n' 41 ' --genome GENOME \\s+ Path to genome file\n' 42 ' -v\n' 43- ' -g MY_CFG_FILE, --my-cfg-file MY_CFG_FILE\n\n' 44+ ' -g( MY_CFG_FILE)?, --my-cfg-file MY_CFG_FILE\n\n' 45 'g2:\n' 46- ' -d DBSNP, --dbsnp DBSNP\\s+\\[env var: DBSNP_PATH\\]\n' 47- ' -f FRMT, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n\n'%OPTIONAL_ARGS_STRING + 48+ ' -d( DBSNP)?, --dbsnp DBSNP\\s+\\[env var: DBSNP_PATH\\]\n' 49+ ' -f( FRMT)?, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n\n'%OPTIONAL_ARGS_STRING + 50 7*r'(.+\s*)') 51 52 self.assertParseArgsRaises("invalid choice: 'ZZZ'", 53@@ -387,9 +387,9 @@ def testMutuallyExclusiveArgs(self): 54 ' \\s*-f2 TYPE2_CFG_FILE\\)\\s+\\(-f FRMT \\| -b\\)\n\n' 55 '%s:\n' 56 ' -h, --help show this help message and exit\n' 57- ' -f1 TYPE1_CFG_FILE, --type1-cfg-file TYPE1_CFG_FILE\n' 58- ' -f2 TYPE2_CFG_FILE, --type2-cfg-file TYPE2_CFG_FILE\n' 59- ' -f FRMT, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n' 60+ ' -f1( TYPE1_CFG_FILE)?, --type1-cfg-file TYPE1_CFG_FILE\n' 61+ ' -f2( TYPE2_CFG_FILE)?, --type2-cfg-file TYPE2_CFG_FILE\n' 62+ ' -f( FRMT)?, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n' 63 ' -b, --bam\\s+\\[env var: BAM_FORMAT\\]\n\n' 64 'group1:\n' 65 ' --genome GENOME Path to genome file\n' 66@@ -875,7 +875,7 @@ def testConstructor_ConfigFileArgs(self): 67 'usage: .* \\[-h\\] -c CONFIG_FILE --genome GENOME\n\n' 68 '%s:\n' 69 ' -h, --help\\s+ show this help message and exit\n' 70- ' -c CONFIG_FILE, --config CONFIG_FILE\\s+ my config file\n' 71+ ' -c( CONFIG_FILE)?, --config CONFIG_FILE\\s+ my config file\n' 72 ' --genome GENOME\\s+ Path to genome file\n\n'%OPTIONAL_ARGS_STRING + 73 5*r'(.+\s*)') 74 75@@ -935,8 +935,8 @@ def test_FormatHelp(self): 76 r'\[-w CONFIG_OUTPUT_PATH\]\s* --arg1\s+ARG1\s*\[--flag\]\s*' 77 '%s:\\s*' 78 '-h, --help \\s* show this help message and exit ' 79- r'-c CONFIG_FILE, --config CONFIG_FILE\s+my config file ' 80- r'-w CONFIG_OUTPUT_PATH, --write-config CONFIG_OUTPUT_PATH takes ' 81+ r'-c( CONFIG_FILE)?, --config CONFIG_FILE\s+my config file ' 82+ r'-w( CONFIG_OUTPUT_PATH)?, --write-config CONFIG_OUTPUT_PATH takes ' 83 r'the current command line args and writes them ' 84 r'out to a config file at the given path, then exits ' 85 r'--arg1 ARG1 Arg1 help text ' 86 87From 5e9f442374bc6d9707a43df13aaff684dff6b535 Mon Sep 17 00:00:00 2001 88From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> 89Date: Fri, 12 Jul 2024 08:25:30 +0200 90Subject: [PATCH 2/2] skip exit_on_error* tests to fix 3.13 test failures 91 92Skip `exit_on_error*` tests from `test.test_argparse` to avoid test 93failures on Python 3.13. The `exit_on_error=False` semantics 94is not supported by ConfigArgParse at the moment. 95--- 96 tests/test_configargparse.py | 3 ++- 97 1 file changed, 2 insertions(+), 1 deletion(-) 98 99diff --git a/tests/test_configargparse.py b/tests/test_configargparse.py 100index e325afd..9718d86 100644 101--- a/tests/test_configargparse.py 102+++ b/tests/test_configargparse.py 103@@ -1533,7 +1533,8 @@ def testYAMLConfigFileParser_w_ArgumentParser_parsed_values(self): 104 test_argparse_source_code = test_argparse_source_code.replace( 105 'argparse.ArgumentParser', 'configargparse.ArgumentParser').replace( 106 'TestHelpFormattingMetaclass', '_TestHelpFormattingMetaclass').replace( 107- 'test_main', '_test_main') 108+ 'test_main', '_test_main').replace( 109+ 'test_exit_on_error', '_test_exit_on_error') 110 111 # pytest tries to collect tests from TestHelpFormattingMetaclass, and 112 # test_main, and raises a warning when it finds it's not a test class