Repository: borgbackup/borg

Issue:
argparse issue with py 3.7.0?
py370 argparse issue?
```
_________________________________________________________________________________ TestCommonOptions.test_simple __________________________________________________________________________________
[gw1] linux -- Python 3.7.0 /home/tw/w/borg/.tox/py37/bin/python3.7

self = <borg.testsuite.archiver.TestCommonOptions object at 0x7f6737889128>
parse_vars_from_line = <function TestCommonOptions.parse_vars_from_line.<locals>.parse_vars_from_line at 0x7f67378a38c8>

    def test_simple(self, parse_vars_from_line):
>       assert parse_vars_from_line('--error') == {
            'append': [],
            'lock_wait': 1,
            'log_level': 'error',
            'progress': False
        }

.tox/py37/lib/python3.7/site-packages/borg/testsuite/archiver.py:3707: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py37/lib/python3.7/site-packages/borg/testsuite/archiver.py:3700: in parse_vars_from_line
    args = parser.parse_args(line)
/usr/lib/python3.7/argparse.py:1754: in parse_args
    args, argv = self.parse_known_args(args, namespace)
/usr/lib/python3.7/argparse.py:1786: in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
/usr/lib/python3.7/argparse.py:2021: in _parse_known_args
    ', '.join(required_actions))
/usr/lib/python3.7/argparse.py:2506: in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = ArgumentParser(prog='test', usage=None, description='test parser', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=False), status = 2
message = 'test: error: the following arguments are required: <command>\n'

    def exit(self, status=0, message=None):
        if message:
            self._print_message(message, _sys.stderr)
>       _sys.exit(status)
E       SystemExit: 2

/usr/lib/python3.7/argparse.py:2493: SystemExit
-------------------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------------------
('--error',)
-------------------------------------------------------------------------------------- Captured stderr call ---------------------------------------------------------------------------------------
usage: test [-h] [--critical] [--error] [--append TOPIC] [-p] [--lock-wait N]
            <command> ...
test: error: the following arguments are required: <command>
________________________________________________________________________ RemoteArchiverTestCase.test_extract_capabilities _________________________________________________________________________

```


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -830,6 +830,7 @@ def run(self):
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
         'Programming Language :: Python :: 3.6',
+        'Programming Language :: Python :: 3.7',
         'Topic :: Security :: Cryptography',
         'Topic :: System :: Archiving :: Backup',
     ],
diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -3673,7 +3673,13 @@ def basic_parser(self):
 
     @pytest.fixture
     def subparsers(self, basic_parser):
-        return basic_parser.add_subparsers(title='required arguments', metavar='<command>')
+        if sys.version_info >= (3, 7):
+            # py37 pre-release defaults to unwanted required=True, in 3.7.0+ it was fixed to =False
+            return basic_parser.add_subparsers(title='required arguments', metavar='<command>', required=False)
+        else:
+            # py36 does not support required=... argument (but behaves like required=False).
+            # note: use below call for 3.6 and 3.7 when there are no alphas/betas/RCs of 3.7.0 around any more.
+            return basic_parser.add_subparsers(title='required arguments', metavar='<command>')
 
     @pytest.fixture
     def parser(self, basic_parser):


Test patch: