|
1 | 1 | import configparser
|
2 |
| -# import os |
3 | 2 |
|
4 | 3 | config =configparser.ConfigParser()
|
5 |
| -# config.read("configurations/config.ini") |
6 |
| -config.read(r"C:\Users\pfarakate\OneDrive - Infor\Frameworks\Demo_Framework\api-automation-framework-python\configurations\config.ini") |
7 |
| -# config_path = os.path.join(os.path.dirname(__file__), "configurations/config.ini") |
8 |
| -# config.read(config_path) |
| 4 | +config.read("configurations/config.ini") |
| 5 | + |
9 | 6 |
|
10 | 7 | class ReadConfig:
|
11 | 8 | @staticmethod
|
12 | 9 | def get_base_url():
|
13 | 10 | return config.get("restfulBooker", "base_url")
|
14 | 11 |
|
15 | 12 |
|
16 |
| -# import os |
17 |
| -# import configparser |
18 |
| -# |
19 |
| -# class ReadConfig: |
20 |
| -# @staticmethod |
21 |
| -# def get_base_url(): |
22 |
| -# config = configparser.ConfigParser() |
23 |
| -# # Dynamically get the absolute path of config.ini |
24 |
| -# config_path = os.path.join(os.path.dirname(__file__), '../config.ini') |
25 |
| -# if not os.path.exists(config_path): |
26 |
| -# raise FileNotFoundError(f"Configuration file not found at {config_path}") |
27 |
| -# config.read(config_path) |
28 |
| -# if "restfulBooker" not in config: |
29 |
| -# raise KeyError(f"'restfulBooker' section not found in {config_path}") |
30 |
| -# return config.get("restfulBooker", "base_url") |
31 |
| - |
32 |
| -# import os |
33 |
| -# import configparser |
34 |
| -# |
35 |
| -# |
36 |
| -# class ReadConfig: |
37 |
| -# @staticmethod |
38 |
| -# def get_base_url(): |
39 |
| -# config = configparser.ConfigParser() |
40 |
| -# |
41 |
| -# # Dynamically get the absolute path of config.ini |
42 |
| -# config_path = os.path.join(os.path.dirname(__file__), '../config.ini') |
43 |
| -# |
44 |
| -# # Check if the config file exists |
45 |
| -# if not os.path.exists(config_path): |
46 |
| -# raise FileNotFoundError(f"Configuration file not found at {config_path}") |
47 |
| -# |
48 |
| -# # Read the config file |
49 |
| -# config.read(config_path) |
50 |
| -# |
51 |
| -# # Verify the section exists |
52 |
| -# if "restfulBooker" not in config: |
53 |
| -# raise KeyError(f"'restfulBooker' section not found in {config_path}") |
54 |
| -# |
55 |
| -# # Get the base_url value |
56 |
| -# try: |
57 |
| -# base_url = config.get("restfulBooker", "base_url") |
58 |
| -# except configparser.NoOptionError: |
59 |
| -# raise KeyError(f"'base_url' option not found in 'restfulBooker' section of {config_path}") |
60 |
| -# |
61 |
| -# return base_url |
0 commit comments