source: mod_gnutls/test/https-test-client.py @ b307cc1

asyncioproxy-ticket
Last change on this file since b307cc1 was c7f83a3, checked in by Fiona Klute <fiona.klute@…>, 13 months ago

https-test-client.py: Always close the test config file

  • Property mode set to 100755
File size: 1.9 KB
RevLine 
[618ee14]1#!/usr/bin/python3
2# PYTHON_ARGCOMPLETE_OK
3
4# Copyright 2019 Fiona Klute
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
[e3e0de1]18import os
[618ee14]19
[c96a965]20from mgstest.tests import run_test_conf
[618ee14]21
22if __name__ == "__main__":
23    import argparse
24    parser = argparse.ArgumentParser(
25        description='Send HTTP requests through gnutls-cli',
26        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
[e3e0de1]27    parser.add_argument('host', nargs='?', default=None,
28                        help='Access this host. Overrides TEST_TARGET, '
29                        'but not the test configuration file.')
30    parser.add_argument('-p', '--port', default=None,
31                        help='Access this port. Overrides TEST_PORT, '
32                        'but not the test configuration file.')
[42097fb]33    parser.add_argument('--timeout', type=float,
34                        help='Timeout for HTTP requests', default='5.0')
[d5f5356]35    parser.add_argument('--test-config', type=argparse.FileType('r'),
[2e736df]36                        required=True, help='load YAML test configuration')
[618ee14]37
38    # enable bash completion if argcomplete is available
39    try:
40        import argcomplete
41        argcomplete.autocomplete(parser)
42    except ImportError:
43        pass
44
45    args = parser.parse_args()
46
[e3e0de1]47    if args.host:
48        os.environ['TEST_TARGET'] = args.host
49    if args.port:
50        os.environ['TEST_PORT'] = args.port
51
[c7f83a3]52    try:
53        run_test_conf(args.test_config, args.timeout)
54    finally:
55        args.test_config.close()
Note: See TracBrowser for help on using the repository browser.