MCPcopy
hub / github.com/dlt-hub/dlt / pytest_configure

Function pytest_configure

tests/conftest.py:100–200  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

98
99
100def pytest_configure(config):
101 # patch the configurations to use test storage by default, we modify the types (classes) fields
102 # the dataclass implementation will use those patched values when creating instances (the values present
103 # in the declaration are not frozen allowing patching). this is needed by common storage tests
104 from tests.utils import set_environment_test_storage_root, compute_test_storage_root
105
106 test_storage_root = compute_test_storage_root()
107 Path(test_storage_root).mkdir(exist_ok=True)
108 set_environment_test_storage_root(test_storage_root)
109
110 from dlt.common.configuration.specs import runtime_configuration
111 from dlt.common.storages import configuration as storage_configuration
112
113 runtime_configuration.RuntimeConfiguration.config_files_storage_path = os.path.join(
114 test_storage_root, "config/"
115 )
116 # always use CI track endpoint when running tests
117 runtime_configuration.RuntimeConfiguration.dlthub_telemetry_endpoint = (
118 "https://telemetry-tracker.services4758.workers.dev"
119 )
120
121 del runtime_configuration.RuntimeConfiguration.__init__
122 runtime_configuration.RuntimeConfiguration = dataclasses.dataclass( # type: ignore[misc]
123 runtime_configuration.RuntimeConfiguration, init=True, repr=False
124 )
125
126 storage_configuration.LoadStorageConfiguration.load_volume_path = os.path.join(
127 test_storage_root, "load"
128 )
129 del storage_configuration.LoadStorageConfiguration.__init__
130 storage_configuration.LoadStorageConfiguration = dataclasses.dataclass( # type: ignore[misc]
131 storage_configuration.LoadStorageConfiguration, init=True, repr=False
132 )
133
134 storage_configuration.NormalizeStorageConfiguration.normalize_volume_path = os.path.join(
135 test_storage_root, "normalize"
136 )
137 # delete __init__, otherwise it will not be recreated by dataclass
138 del storage_configuration.NormalizeStorageConfiguration.__init__
139 storage_configuration.NormalizeStorageConfiguration = dataclasses.dataclass( # type: ignore[misc]
140 storage_configuration.NormalizeStorageConfiguration, init=True, repr=False
141 )
142
143 storage_configuration.SchemaStorageConfiguration.schema_volume_path = os.path.join(
144 test_storage_root, "schemas"
145 )
146 del storage_configuration.SchemaStorageConfiguration.__init__
147 storage_configuration.SchemaStorageConfiguration = dataclasses.dataclass( # type: ignore[misc]
148 storage_configuration.SchemaStorageConfiguration, init=True, repr=False
149 )
150
151 assert runtime_configuration.RuntimeConfiguration.config_files_storage_path == os.path.join(
152 test_storage_root, "config/"
153 )
154 assert runtime_configuration.RuntimeConfiguration().config_files_storage_path == os.path.join(
155 test_storage_root, "config/"
156 )
157

Callers

nothing calls this directly

Calls 4

mkdirMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected