File: config.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (42 lines) | stat: -rw-r--r-- 1,422 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
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
import configargparse
import os

from dotenv import load_dotenv, find_dotenv

load_dotenv(find_dotenv())


ENV_LIVE_TEST = "AZURE_TEST_RUN_LIVE"
PROXY_URL = os.getenv("PROXY_URL", "https://localhost:5001").rstrip("/")
TEST_SETTING_FILENAME = "testsettings_local.cfg"


class TestConfig(object):  # pylint: disable=too-few-public-methods
    def __init__(self, parent_parsers=None, config_file=None):
        parent_parsers = parent_parsers or []
        self.parser = configargparse.ArgumentParser(parents=parent_parsers)
        self.parser.add_argument(
            "-c",
            "--config",
            is_config_file=True,
            default=config_file,
            help="Path to a configuration file in YAML format.",
        )
        self.parser.add_argument(
            "-l",
            "--live-mode",
            action="store_true",
            dest="live_mode",
            env_var=ENV_LIVE_TEST,
            help='Activate "live" recording mode for tests.',
        )
        self.args = self.parser.parse_args([])

    @property
    def record_mode(self):
        return self.args.live_mode