provide-foundation 0.0.0.dev2__py3-none-any.whl → 0.0.0.dev3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- provide/foundation/__init__.py +20 -20
- provide/foundation/archive/__init__.py +1 -1
- provide/foundation/archive/base.py +15 -14
- provide/foundation/archive/bzip2.py +40 -40
- provide/foundation/archive/gzip.py +42 -42
- provide/foundation/archive/operations.py +90 -91
- provide/foundation/archive/tar.py +33 -31
- provide/foundation/archive/zip.py +52 -50
- provide/foundation/asynctools/__init__.py +20 -0
- provide/foundation/asynctools/core.py +126 -0
- provide/foundation/cli/__init__.py +2 -2
- provide/foundation/cli/commands/deps.py +4 -4
- provide/foundation/cli/commands/logs/__init__.py +2 -2
- provide/foundation/cli/commands/logs/generate.py +2 -2
- provide/foundation/cli/commands/logs/query.py +3 -3
- provide/foundation/cli/commands/logs/send.py +2 -2
- provide/foundation/cli/commands/logs/tail.py +2 -2
- provide/foundation/cli/decorators.py +0 -1
- provide/foundation/cli/testing.py +0 -5
- provide/foundation/cli/utils.py +1 -2
- provide/foundation/config/__init__.py +19 -19
- provide/foundation/config/base.py +2 -2
- provide/foundation/config/converters.py +81 -83
- provide/foundation/config/defaults.py +1 -1
- provide/foundation/config/env.py +2 -1
- provide/foundation/config/loader.py +1 -1
- provide/foundation/config/sync.py +8 -6
- provide/foundation/config/types.py +5 -5
- provide/foundation/config/validators.py +4 -4
- provide/foundation/console/output.py +7 -7
- provide/foundation/context/core.py +19 -17
- provide/foundation/crypto/certificates/__init__.py +9 -5
- provide/foundation/crypto/certificates/base.py +2 -2
- provide/foundation/crypto/certificates/certificate.py +48 -19
- provide/foundation/crypto/certificates/factory.py +26 -18
- provide/foundation/crypto/certificates/generator.py +24 -23
- provide/foundation/crypto/certificates/loader.py +24 -16
- provide/foundation/crypto/certificates/operations.py +17 -10
- provide/foundation/crypto/certificates/trust.py +21 -21
- provide/foundation/env/__init__.py +28 -0
- provide/foundation/env/core.py +218 -0
- provide/foundation/errors/__init__.py +3 -2
- provide/foundation/errors/decorators.py +0 -3
- provide/foundation/errors/types.py +0 -1
- provide/foundation/eventsets/display.py +13 -14
- provide/foundation/eventsets/registry.py +61 -31
- provide/foundation/eventsets/resolver.py +50 -46
- provide/foundation/eventsets/sets/das.py +8 -8
- provide/foundation/eventsets/sets/database.py +14 -14
- provide/foundation/eventsets/sets/http.py +21 -21
- provide/foundation/eventsets/sets/llm.py +16 -16
- provide/foundation/eventsets/sets/task_queue.py +13 -13
- provide/foundation/eventsets/types.py +7 -7
- provide/foundation/file/directory.py +1 -1
- provide/foundation/file/lock.py +2 -3
- provide/foundation/hub/components.py +19 -21
- provide/foundation/hub/config.py +25 -19
- provide/foundation/hub/discovery.py +5 -4
- provide/foundation/hub/handlers.py +13 -5
- provide/foundation/hub/lifecycle.py +10 -9
- provide/foundation/hub/manager.py +3 -0
- provide/foundation/hub/processors.py +8 -3
- provide/foundation/integrations/__init__.py +1 -1
- provide/foundation/integrations/openobserve/client.py +2 -2
- provide/foundation/integrations/openobserve/commands.py +9 -9
- provide/foundation/integrations/openobserve/config.py +2 -2
- provide/foundation/integrations/openobserve/otlp.py +2 -2
- provide/foundation/integrations/openobserve/search.py +1 -2
- provide/foundation/integrations/openobserve/streaming.py +1 -1
- provide/foundation/logger/__init__.py +0 -1
- provide/foundation/logger/config/base.py +1 -1
- provide/foundation/logger/config/logging.py +19 -19
- provide/foundation/logger/config/telemetry.py +11 -13
- provide/foundation/logger/factories.py +2 -2
- provide/foundation/logger/processors/main.py +12 -10
- provide/foundation/logger/ratelimit/limiters.py +4 -4
- provide/foundation/logger/ratelimit/processor.py +1 -1
- provide/foundation/logger/setup/coordinator.py +38 -24
- provide/foundation/logger/setup/processors.py +3 -3
- provide/foundation/logger/setup/testing.py +14 -0
- provide/foundation/logger/trace.py +5 -5
- provide/foundation/metrics/__init__.py +1 -1
- provide/foundation/metrics/otel.py +3 -1
- provide/foundation/observability/__init__.py +1 -1
- provide/foundation/process/__init__.py +1 -1
- provide/foundation/process/exit.py +6 -5
- provide/foundation/process/lifecycle.py +41 -18
- provide/foundation/resilience/__init__.py +6 -5
- provide/foundation/resilience/circuit.py +32 -30
- provide/foundation/resilience/decorators.py +58 -42
- provide/foundation/resilience/fallback.py +55 -40
- provide/foundation/resilience/retry.py +67 -65
- provide/foundation/serialization/__init__.py +16 -0
- provide/foundation/serialization/core.py +70 -0
- provide/foundation/streams/config.py +8 -9
- provide/foundation/streams/console.py +3 -3
- provide/foundation/streams/core.py +2 -2
- provide/foundation/streams/file.py +1 -1
- provide/foundation/testing/__init__.py +22 -7
- provide/foundation/testing/archive/__init__.py +7 -7
- provide/foundation/testing/archive/fixtures.py +58 -54
- provide/foundation/testing/cli.py +3 -6
- provide/foundation/testing/common/__init__.py +13 -13
- provide/foundation/testing/common/fixtures.py +27 -30
- provide/foundation/testing/file/__init__.py +15 -15
- provide/foundation/testing/file/content_fixtures.py +65 -92
- provide/foundation/testing/file/directory_fixtures.py +19 -19
- provide/foundation/testing/file/fixtures.py +14 -17
- provide/foundation/testing/file/special_fixtures.py +34 -42
- provide/foundation/testing/logger.py +28 -23
- provide/foundation/testing/mocking/__init__.py +21 -21
- provide/foundation/testing/mocking/fixtures.py +80 -67
- provide/foundation/testing/process/__init__.py +23 -23
- provide/foundation/testing/process/async_fixtures.py +89 -80
- provide/foundation/testing/process/fixtures.py +11 -13
- provide/foundation/testing/process/subprocess_fixtures.py +41 -40
- provide/foundation/testing/threading/__init__.py +17 -17
- provide/foundation/testing/threading/basic_fixtures.py +21 -17
- provide/foundation/testing/threading/data_fixtures.py +18 -16
- provide/foundation/testing/threading/execution_fixtures.py +67 -52
- provide/foundation/testing/threading/fixtures.py +10 -14
- provide/foundation/testing/threading/sync_fixtures.py +21 -18
- provide/foundation/testing/time/__init__.py +11 -11
- provide/foundation/testing/time/fixtures.py +91 -79
- provide/foundation/testing/transport/__init__.py +9 -9
- provide/foundation/testing/transport/fixtures.py +54 -54
- provide/foundation/time/__init__.py +18 -0
- provide/foundation/time/core.py +63 -0
- provide/foundation/tools/__init__.py +2 -2
- provide/foundation/tools/base.py +68 -67
- provide/foundation/tools/cache.py +62 -69
- provide/foundation/tools/downloader.py +51 -56
- provide/foundation/tools/installer.py +51 -57
- provide/foundation/tools/registry.py +38 -45
- provide/foundation/tools/resolver.py +70 -68
- provide/foundation/tools/verifier.py +39 -50
- provide/foundation/tracer/spans.py +1 -13
- provide/foundation/transport/__init__.py +26 -33
- provide/foundation/transport/base.py +32 -30
- provide/foundation/transport/client.py +44 -49
- provide/foundation/transport/config.py +11 -13
- provide/foundation/transport/errors.py +13 -27
- provide/foundation/transport/http.py +69 -55
- provide/foundation/transport/middleware.py +86 -81
- provide/foundation/transport/registry.py +29 -27
- provide/foundation/transport/types.py +6 -6
- provide/foundation/utils/deps.py +3 -2
- provide/foundation/utils/parsing.py +7 -7
- {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/METADATA +2 -2
- provide_foundation-0.0.0.dev3.dist-info/RECORD +233 -0
- provide_foundation-0.0.0.dev2.dist-info/RECORD +0 -225
- {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/WHEEL +0 -0
- {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/entry_points.txt +0 -0
- {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/licenses/LICENSE +0 -0
- {provide_foundation-0.0.0.dev2.dist-info → provide_foundation-0.0.0.dev3.dist-info}/top_level.txt +0 -0
@@ -7,9 +7,9 @@ CSV, JSON, and other structured data.
|
|
7
7
|
|
8
8
|
import csv
|
9
9
|
import json
|
10
|
+
from pathlib import Path
|
10
11
|
import random
|
11
12
|
import tempfile
|
12
|
-
from pathlib import Path
|
13
13
|
|
14
14
|
import pytest
|
15
15
|
|
@@ -20,31 +20,31 @@ from provide.foundation.file.safe import safe_delete
|
|
20
20
|
def temp_file():
|
21
21
|
"""
|
22
22
|
Create a temporary file factory with optional content.
|
23
|
-
|
23
|
+
|
24
24
|
Returns:
|
25
25
|
A function that creates temporary files with specified content and suffix.
|
26
26
|
"""
|
27
27
|
created_files = []
|
28
|
-
|
28
|
+
|
29
29
|
def _make_temp_file(content: str = "test content", suffix: str = ".txt") -> Path:
|
30
30
|
"""
|
31
31
|
Create a temporary file.
|
32
|
-
|
32
|
+
|
33
33
|
Args:
|
34
34
|
content: Content to write to the file
|
35
35
|
suffix: File suffix/extension
|
36
|
-
|
36
|
+
|
37
37
|
Returns:
|
38
38
|
Path to the created temporary file
|
39
39
|
"""
|
40
|
-
with tempfile.NamedTemporaryFile(mode=
|
40
|
+
with tempfile.NamedTemporaryFile(mode="w", suffix=suffix, delete=False) as f:
|
41
41
|
f.write(content)
|
42
42
|
path = Path(f.name)
|
43
43
|
created_files.append(path)
|
44
44
|
return path
|
45
|
-
|
45
|
+
|
46
46
|
yield _make_temp_file
|
47
|
-
|
47
|
+
|
48
48
|
# Cleanup all created files
|
49
49
|
for path in created_files:
|
50
50
|
safe_delete(path, missing_ok=True)
|
@@ -54,23 +54,23 @@ def temp_file():
|
|
54
54
|
def temp_named_file():
|
55
55
|
"""
|
56
56
|
Create a named temporary file factory.
|
57
|
-
|
57
|
+
|
58
58
|
Returns:
|
59
59
|
Function that creates named temporary files.
|
60
60
|
"""
|
61
61
|
created_files = []
|
62
|
-
|
62
|
+
|
63
63
|
def _make_named_file(
|
64
64
|
content: bytes | str = None,
|
65
65
|
suffix: str = "",
|
66
66
|
prefix: str = "tmp",
|
67
67
|
dir: Path | str = None,
|
68
|
-
mode: str =
|
69
|
-
delete: bool = False
|
68
|
+
mode: str = "w+b",
|
69
|
+
delete: bool = False,
|
70
70
|
) -> Path:
|
71
71
|
"""
|
72
72
|
Create a named temporary file.
|
73
|
-
|
73
|
+
|
74
74
|
Args:
|
75
75
|
content: Optional content to write
|
76
76
|
suffix: File suffix
|
@@ -78,41 +78,37 @@ def temp_named_file():
|
|
78
78
|
dir: Directory for the file
|
79
79
|
mode: File mode
|
80
80
|
delete: Whether to delete on close
|
81
|
-
|
81
|
+
|
82
82
|
Returns:
|
83
83
|
Path to the created file
|
84
84
|
"""
|
85
85
|
if isinstance(dir, Path):
|
86
86
|
dir = str(dir)
|
87
|
-
|
87
|
+
|
88
88
|
f = tempfile.NamedTemporaryFile(
|
89
|
-
mode=mode,
|
90
|
-
suffix=suffix,
|
91
|
-
prefix=prefix,
|
92
|
-
dir=dir,
|
93
|
-
delete=delete
|
89
|
+
mode=mode, suffix=suffix, prefix=prefix, dir=dir, delete=delete
|
94
90
|
)
|
95
|
-
|
91
|
+
|
96
92
|
if content is not None:
|
97
93
|
if isinstance(content, str):
|
98
|
-
if
|
94
|
+
if "b" in mode:
|
99
95
|
f.write(content.encode())
|
100
96
|
else:
|
101
97
|
f.write(content)
|
102
98
|
else:
|
103
99
|
f.write(content)
|
104
100
|
f.flush()
|
105
|
-
|
101
|
+
|
106
102
|
path = Path(f.name)
|
107
103
|
f.close()
|
108
|
-
|
104
|
+
|
109
105
|
if not delete:
|
110
106
|
created_files.append(path)
|
111
|
-
|
107
|
+
|
112
108
|
return path
|
113
|
-
|
109
|
+
|
114
110
|
yield _make_named_file
|
115
|
-
|
111
|
+
|
116
112
|
# Cleanup
|
117
113
|
for path in created_files:
|
118
114
|
safe_delete(path, missing_ok=True)
|
@@ -122,42 +118,40 @@ def temp_named_file():
|
|
122
118
|
def temp_file_with_content():
|
123
119
|
"""
|
124
120
|
Create temporary files with specific content.
|
125
|
-
|
121
|
+
|
126
122
|
Returns:
|
127
123
|
Function that creates files with content.
|
128
124
|
"""
|
129
125
|
created_files = []
|
130
|
-
|
126
|
+
|
131
127
|
def _make_file(
|
132
|
-
content: str | bytes,
|
133
|
-
suffix: str = ".txt",
|
134
|
-
encoding: str = "utf-8"
|
128
|
+
content: str | bytes, suffix: str = ".txt", encoding: str = "utf-8"
|
135
129
|
) -> Path:
|
136
130
|
"""
|
137
131
|
Create a temporary file with content.
|
138
|
-
|
132
|
+
|
139
133
|
Args:
|
140
134
|
content: Content to write
|
141
135
|
suffix: File suffix
|
142
136
|
encoding: Text encoding (for str content)
|
143
|
-
|
137
|
+
|
144
138
|
Returns:
|
145
139
|
Path to created file
|
146
140
|
"""
|
147
141
|
with tempfile.NamedTemporaryFile(
|
148
|
-
mode=
|
142
|
+
mode="wb" if isinstance(content, bytes) else "w",
|
149
143
|
suffix=suffix,
|
150
144
|
delete=False,
|
151
|
-
encoding=None if isinstance(content, bytes) else encoding
|
145
|
+
encoding=None if isinstance(content, bytes) else encoding,
|
152
146
|
) as f:
|
153
147
|
f.write(content)
|
154
148
|
path = Path(f.name)
|
155
|
-
|
149
|
+
|
156
150
|
created_files.append(path)
|
157
151
|
return path
|
158
|
-
|
152
|
+
|
159
153
|
yield _make_file
|
160
|
-
|
154
|
+
|
161
155
|
# Cleanup
|
162
156
|
for path in created_files:
|
163
157
|
safe_delete(path, missing_ok=True)
|
@@ -167,25 +161,23 @@ def temp_file_with_content():
|
|
167
161
|
def temp_binary_file():
|
168
162
|
"""
|
169
163
|
Create temporary binary files.
|
170
|
-
|
164
|
+
|
171
165
|
Returns:
|
172
166
|
Function that creates binary files.
|
173
167
|
"""
|
174
168
|
created_files = []
|
175
|
-
|
169
|
+
|
176
170
|
def _make_binary(
|
177
|
-
size: int = 1024,
|
178
|
-
pattern: bytes = None,
|
179
|
-
suffix: str = ".bin"
|
171
|
+
size: int = 1024, pattern: bytes = None, suffix: str = ".bin"
|
180
172
|
) -> Path:
|
181
173
|
"""
|
182
174
|
Create a temporary binary file.
|
183
|
-
|
175
|
+
|
184
176
|
Args:
|
185
177
|
size: File size in bytes
|
186
178
|
pattern: Optional byte pattern to repeat
|
187
179
|
suffix: File suffix
|
188
|
-
|
180
|
+
|
189
181
|
Returns:
|
190
182
|
Path to created binary file
|
191
183
|
"""
|
@@ -196,20 +188,16 @@ def temp_binary_file():
|
|
196
188
|
# Repeat pattern to reach size
|
197
189
|
repetitions = size // len(pattern) + 1
|
198
190
|
content = (pattern * repetitions)[:size]
|
199
|
-
|
200
|
-
with tempfile.NamedTemporaryFile(
|
201
|
-
mode='wb',
|
202
|
-
suffix=suffix,
|
203
|
-
delete=False
|
204
|
-
) as f:
|
191
|
+
|
192
|
+
with tempfile.NamedTemporaryFile(mode="wb", suffix=suffix, delete=False) as f:
|
205
193
|
f.write(content)
|
206
194
|
path = Path(f.name)
|
207
|
-
|
195
|
+
|
208
196
|
created_files.append(path)
|
209
197
|
return path
|
210
|
-
|
198
|
+
|
211
199
|
yield _make_binary
|
212
|
-
|
200
|
+
|
213
201
|
# Cleanup
|
214
202
|
for path in created_files:
|
215
203
|
safe_delete(path, missing_ok=True)
|
@@ -219,44 +207,37 @@ def temp_binary_file():
|
|
219
207
|
def temp_csv_file():
|
220
208
|
"""
|
221
209
|
Create temporary CSV files for testing.
|
222
|
-
|
210
|
+
|
223
211
|
Returns:
|
224
212
|
Function that creates CSV files.
|
225
213
|
"""
|
226
214
|
created_files = []
|
227
|
-
|
228
|
-
def _make_csv(
|
229
|
-
headers: list[str],
|
230
|
-
rows: list[list],
|
231
|
-
suffix: str = ".csv"
|
232
|
-
) -> Path:
|
215
|
+
|
216
|
+
def _make_csv(headers: list[str], rows: list[list], suffix: str = ".csv") -> Path:
|
233
217
|
"""
|
234
218
|
Create a temporary CSV file.
|
235
|
-
|
219
|
+
|
236
220
|
Args:
|
237
221
|
headers: Column headers
|
238
222
|
rows: Data rows
|
239
223
|
suffix: File suffix
|
240
|
-
|
224
|
+
|
241
225
|
Returns:
|
242
226
|
Path to created CSV file
|
243
227
|
"""
|
244
228
|
with tempfile.NamedTemporaryFile(
|
245
|
-
mode=
|
246
|
-
suffix=suffix,
|
247
|
-
delete=False,
|
248
|
-
newline=''
|
229
|
+
mode="w", suffix=suffix, delete=False, newline=""
|
249
230
|
) as f:
|
250
231
|
writer = csv.writer(f)
|
251
232
|
writer.writerow(headers)
|
252
233
|
writer.writerows(rows)
|
253
234
|
path = Path(f.name)
|
254
|
-
|
235
|
+
|
255
236
|
created_files.append(path)
|
256
237
|
return path
|
257
|
-
|
238
|
+
|
258
239
|
yield _make_csv
|
259
|
-
|
240
|
+
|
260
241
|
# Cleanup
|
261
242
|
for path in created_files:
|
262
243
|
safe_delete(path, missing_ok=True)
|
@@ -266,51 +247,43 @@ def temp_csv_file():
|
|
266
247
|
def temp_json_file():
|
267
248
|
"""
|
268
249
|
Create temporary JSON files for testing.
|
269
|
-
|
250
|
+
|
270
251
|
Returns:
|
271
252
|
Function that creates JSON files.
|
272
253
|
"""
|
273
254
|
created_files = []
|
274
|
-
|
275
|
-
def _make_json(
|
276
|
-
data: dict | list,
|
277
|
-
suffix: str = ".json",
|
278
|
-
indent: int = 2
|
279
|
-
) -> Path:
|
255
|
+
|
256
|
+
def _make_json(data: dict | list, suffix: str = ".json", indent: int = 2) -> Path:
|
280
257
|
"""
|
281
258
|
Create a temporary JSON file.
|
282
|
-
|
259
|
+
|
283
260
|
Args:
|
284
261
|
data: JSON data to write
|
285
262
|
suffix: File suffix
|
286
263
|
indent: JSON indentation
|
287
|
-
|
264
|
+
|
288
265
|
Returns:
|
289
266
|
Path to created JSON file
|
290
267
|
"""
|
291
|
-
with tempfile.NamedTemporaryFile(
|
292
|
-
mode='w',
|
293
|
-
suffix=suffix,
|
294
|
-
delete=False
|
295
|
-
) as f:
|
268
|
+
with tempfile.NamedTemporaryFile(mode="w", suffix=suffix, delete=False) as f:
|
296
269
|
json.dump(data, f, indent=indent)
|
297
270
|
path = Path(f.name)
|
298
|
-
|
271
|
+
|
299
272
|
created_files.append(path)
|
300
273
|
return path
|
301
|
-
|
274
|
+
|
302
275
|
yield _make_json
|
303
|
-
|
276
|
+
|
304
277
|
# Cleanup
|
305
278
|
for path in created_files:
|
306
279
|
safe_delete(path, missing_ok=True)
|
307
280
|
|
308
281
|
|
309
282
|
__all__ = [
|
310
|
-
"temp_file",
|
311
|
-
"temp_named_file",
|
312
|
-
"temp_file_with_content",
|
313
283
|
"temp_binary_file",
|
314
284
|
"temp_csv_file",
|
285
|
+
"temp_file",
|
286
|
+
"temp_file_with_content",
|
315
287
|
"temp_json_file",
|
316
|
-
|
288
|
+
"temp_named_file",
|
289
|
+
]
|
@@ -1,13 +1,13 @@
|
|
1
1
|
"""
|
2
2
|
Directory-specific test fixtures.
|
3
3
|
|
4
|
-
Fixtures for creating temporary directories, nested structures,
|
4
|
+
Fixtures for creating temporary directories, nested structures,
|
5
5
|
and standard test directory layouts.
|
6
6
|
"""
|
7
7
|
|
8
|
-
import tempfile
|
9
|
-
from pathlib import Path
|
10
8
|
from collections.abc import Generator
|
9
|
+
from pathlib import Path
|
10
|
+
import tempfile
|
11
11
|
|
12
12
|
import pytest
|
13
13
|
|
@@ -16,7 +16,7 @@ import pytest
|
|
16
16
|
def temp_directory() -> Generator[Path, None, None]:
|
17
17
|
"""
|
18
18
|
Create a temporary directory that's cleaned up after test.
|
19
|
-
|
19
|
+
|
20
20
|
Yields:
|
21
21
|
Path to the temporary directory.
|
22
22
|
"""
|
@@ -28,14 +28,14 @@ def temp_directory() -> Generator[Path, None, None]:
|
|
28
28
|
def test_files_structure() -> Generator[tuple[Path, Path], None, None]:
|
29
29
|
"""
|
30
30
|
Create standard test file structure with files and subdirectories.
|
31
|
-
|
31
|
+
|
32
32
|
Creates:
|
33
33
|
- source/
|
34
34
|
- file1.txt (contains "Content 1")
|
35
35
|
- file2.txt (contains "Content 2")
|
36
36
|
- subdir/
|
37
37
|
- file3.txt (contains "Content 3")
|
38
|
-
|
38
|
+
|
39
39
|
Yields:
|
40
40
|
Tuple of (temp_path, source_path)
|
41
41
|
"""
|
@@ -43,16 +43,16 @@ def test_files_structure() -> Generator[tuple[Path, Path], None, None]:
|
|
43
43
|
path = Path(temp_dir)
|
44
44
|
source = path / "source"
|
45
45
|
source.mkdir()
|
46
|
-
|
46
|
+
|
47
47
|
# Create test files
|
48
48
|
(source / "file1.txt").write_text("Content 1")
|
49
49
|
(source / "file2.txt").write_text("Content 2")
|
50
|
-
|
50
|
+
|
51
51
|
# Create subdirectory with files
|
52
52
|
subdir = source / "subdir"
|
53
53
|
subdir.mkdir()
|
54
54
|
(subdir / "file3.txt").write_text("Content 3")
|
55
|
-
|
55
|
+
|
56
56
|
yield path, source
|
57
57
|
|
58
58
|
|
@@ -60,7 +60,7 @@ def test_files_structure() -> Generator[tuple[Path, Path], None, None]:
|
|
60
60
|
def nested_directory_structure() -> Generator[Path, None, None]:
|
61
61
|
"""
|
62
62
|
Create a deeply nested directory structure for testing.
|
63
|
-
|
63
|
+
|
64
64
|
Creates:
|
65
65
|
- level1/
|
66
66
|
- level2/
|
@@ -68,22 +68,22 @@ def nested_directory_structure() -> Generator[Path, None, None]:
|
|
68
68
|
- deep_file.txt
|
69
69
|
- file_l2.txt
|
70
70
|
- file_l1.txt
|
71
|
-
|
71
|
+
|
72
72
|
Yields:
|
73
73
|
Path to the root of the structure.
|
74
74
|
"""
|
75
75
|
with tempfile.TemporaryDirectory() as temp_dir:
|
76
76
|
root = Path(temp_dir)
|
77
|
-
|
77
|
+
|
78
78
|
# Create nested structure
|
79
79
|
deep_dir = root / "level1" / "level2" / "level3"
|
80
80
|
deep_dir.mkdir(parents=True)
|
81
|
-
|
81
|
+
|
82
82
|
# Add files at different levels
|
83
83
|
(root / "file_l1.txt").write_text("Level 1 file")
|
84
84
|
(root / "level1" / "file_l2.txt").write_text("Level 2 file")
|
85
85
|
(deep_dir / "deep_file.txt").write_text("Deep file")
|
86
|
-
|
86
|
+
|
87
87
|
yield root
|
88
88
|
|
89
89
|
|
@@ -91,7 +91,7 @@ def nested_directory_structure() -> Generator[Path, None, None]:
|
|
91
91
|
def empty_directory() -> Generator[Path, None, None]:
|
92
92
|
"""
|
93
93
|
Create an empty temporary directory.
|
94
|
-
|
94
|
+
|
95
95
|
Yields:
|
96
96
|
Path to an empty directory.
|
97
97
|
"""
|
@@ -100,8 +100,8 @@ def empty_directory() -> Generator[Path, None, None]:
|
|
100
100
|
|
101
101
|
|
102
102
|
__all__ = [
|
103
|
-
"temp_directory",
|
104
|
-
"test_files_structure",
|
105
|
-
"nested_directory_structure",
|
106
103
|
"empty_directory",
|
107
|
-
|
104
|
+
"nested_directory_structure",
|
105
|
+
"temp_directory",
|
106
|
+
"test_files_structure",
|
107
|
+
]
|
@@ -7,34 +7,31 @@ and standard test file structures used across the provide-io ecosystem.
|
|
7
7
|
"""
|
8
8
|
|
9
9
|
# Re-export all fixtures from specialized modules
|
10
|
+
from provide.foundation.testing.file.content_fixtures import (
|
11
|
+
temp_binary_file,
|
12
|
+
temp_csv_file,
|
13
|
+
temp_file,
|
14
|
+
temp_file_with_content,
|
15
|
+
temp_json_file,
|
16
|
+
temp_named_file,
|
17
|
+
)
|
10
18
|
from provide.foundation.testing.file.directory_fixtures import (
|
19
|
+
empty_directory,
|
20
|
+
nested_directory_structure,
|
11
21
|
temp_directory,
|
12
22
|
test_files_structure,
|
13
|
-
nested_directory_structure,
|
14
|
-
empty_directory,
|
15
23
|
)
|
16
|
-
|
17
24
|
from provide.foundation.testing.file.special_fixtures import (
|
18
25
|
binary_file,
|
19
26
|
readonly_file,
|
20
|
-
temp_symlink,
|
21
27
|
temp_executable_file,
|
28
|
+
temp_symlink,
|
22
29
|
)
|
23
30
|
|
24
|
-
from provide.foundation.testing.file.content_fixtures import (
|
25
|
-
temp_file,
|
26
|
-
temp_named_file,
|
27
|
-
temp_file_with_content,
|
28
|
-
temp_binary_file,
|
29
|
-
temp_csv_file,
|
30
|
-
temp_json_file,
|
31
|
-
)
|
32
|
-
|
33
|
-
|
34
31
|
__all__ = [
|
35
32
|
# Directory fixtures
|
36
33
|
"temp_directory",
|
37
|
-
"test_files_structure",
|
34
|
+
"test_files_structure",
|
38
35
|
"nested_directory_structure",
|
39
36
|
"empty_directory",
|
40
37
|
# Special file fixtures
|
@@ -45,8 +42,8 @@ __all__ = [
|
|
45
42
|
# Content-based fixtures
|
46
43
|
"temp_file",
|
47
44
|
"temp_named_file",
|
48
|
-
"temp_file_with_content",
|
45
|
+
"temp_file_with_content",
|
49
46
|
"temp_binary_file",
|
50
47
|
"temp_csv_file",
|
51
48
|
"temp_json_file",
|
52
|
-
]
|
49
|
+
]
|