bw2 / ConfigArgParse

A drop-in replacement for argparse that allows options to also be set via config files and/or environment variables.
MIT License
728 stars 121 forks source link

testMutuallyExclusiveArgs and test_FormatHelp fails with python 3.8 #163

Closed ncopa closed 4 years ago

ncopa commented 5 years ago

There are two tests in 0.15.1 that fails with python 3.8 on Alpine Linux:

======================================================================
FAIL: testMutuallyExclusiveArgs (tests.test_configargparse.TestBasicUseCases)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ncopa/aports/community/py3-configargparse/src/ConfigArgParse-0.15.1/tests/test_configargparse.py", line 32
0, in testMutuallyExclusiveArgs
    self.assertRegex(self.format_help(),
AssertionError: Regex didn't match: 'usage: .* \\[-h\\] --genome GENOME \\[-v\\]\\s+ \\(-f1 TYPE1_CFG_FILE \\| \\s*-f2 T
YPE2_CFG_FILE\\)\\s+\\(-f FRMT \\| -b\\)\n\n.+\\s+.+\\s+.+\\s+.+\\s+.+\\s+.+\\s+.+\\s+optional arguments:\n  -h, --help 
           show this help message and exit\n  -f1 TYPE1_CFG_FILE, --type1-cfg-file TYPE1_CFG_FILE\n  -f2 TYPE2_CFG_FILE,
 --type2-cfg-file TYPE2_CFG_FILE\n  -f FRMT, --format FRMT\\s+\\[env var: OUTPUT_FORMAT\\]\n  -b, --bam\\s+\\[env var: B
AM_FORMAT\\]\n\ngroup1:\n  --genome GENOME       Path to genome file\n  -v\n' not found in "usage: setup.py [-h] --genom
e GENOME [-v] (-f1 TYPE1_CFG_FILE | -f2 TYPE2_CFG_FILE) (-f FRMT | -b)\n\nArgs that start with '--' (eg. --genome) can a
lso be set in a config file (specified via -f1 or -f2). Config file\nsyntax allows: key=value, flag=true, stuff=[a,b,c] 
(for details, see syntax at https://goo.gl/R74nmi). If an arg is\nspecified in more than one place, then commandline val
ues override environment variables which override config file\nvalues which override defaults.\n\noptional arguments:\n 
 -h, --help            show this help message and exit\n  -f1 TYPE1_CFG_FILE, --type1-cfg-file TYPE1_CFG_FILE\n  -f2 TYP
E2_CFG_FILE, --type2-cfg-file TYPE2_CFG_FILE\n  -f FRMT, --format FRMT\n                        [env var: OUTPUT_FORMAT]
\n  -b, --bam             [env var: BAM_FORMAT]\n\ngroup1:\n  --genome GENOME       Path to genome file\n  -v\n"

======================================================================
FAIL: test_FormatHelp (tests.test_configargparse.TestMisc)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ncopa/aports/community/py3-configargparse/src/ConfigArgParse-0.15.1/tests/test_configargparse.py", line 73
4, in test_FormatHelp
    self.assertRegex(self.format_help(),
AssertionError: Regex didn't match: "usage: .* \\[-h\\] -c CONFIG_FILE\\s+\\[-w CONFIG_OUTPUT_PATH\\]\\s* --arg1 ARG1\\s
*\\[--flag\\]\\s*Args that start with '--' \\(eg. --arg1\\) can also be set in a config file\\s*\\(~/.myconfig or specif
ied via -c\\).\\s*Config file syntax allows: key=value,\\s*flag=true, stuff=\\[a,b,c\\] \\(for details, see syntax at ht
tps://goo.gl/R74nmi\\).\\s*If an arg is specified in more than\\s*one place, then commandline values\\s*override config 
file values which override\\s*defaults.\\s*optional arguments:\\s*-h, --help \\s* show this help message and exit\n\\s*-
c CONFIG_FILE, --config CONFIG_FILE\\s+my config file\\s*-w CONFIG_OUTPUT_PATH, --write-config CONFIG_OUTPUT_PATH\\s*tak
es\\s*the current command line args and writes them\\s*out to a config file at the given path, then exits\\s*--arg1 ARG1
\\s*Arg1 help text\\s*--flag \\s*Flag help text" not found in "usage: setup.py [-h] -c CONFIG_FILE [-w CONFIG_OUTPUT_PAT
H] --arg1 ARG1 [--flag]\n\nArgs that start with '--' (eg. --arg1) can also be set in a config file (~/.myconfig or speci
fied via -c). Config file\nsyntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at https://goo.gl
/R74nmi). If an arg is\nspecified in more than one place, then commandline values override config file values which over
ride defaults.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -c CONFIG_FILE, --conf
ig CONFIG_FILE\n                        my config file\n  -w CONFIG_OUTPUT_PATH, --write-config CONFIG_OUTPUT_PATH\n    
                    takes the current command line args and writes them out to a config file at the given path,\n       
                 then exits\n  --arg1 ARG1           Arg1 help text\n  --flag                Flag help text\n"

----------------------------------------------------------------------
Ran 31 tests in 0.958s

FAILED (failures=2)
Test failed: <unittest.runner.TextTestResult run=31 errors=0 failures=2>
error: Test failed: <unittest.runner.TextTestResult run=31 errors=0 failures=2>
mgorny commented 4 years ago

Try setting: export COLUMNS=80 before running tests.

bw2 commented 4 years ago

A PR to fix this would be appreciated.