provide-foundation 0.0.0.dev1__py3-none-any.whl → 0.0.0.dev2__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.
Files changed (93) hide show
  1. provide/foundation/__init__.py +29 -3
  2. provide/foundation/archive/operations.py +4 -6
  3. provide/foundation/cli/__init__.py +2 -2
  4. provide/foundation/cli/commands/deps.py +13 -7
  5. provide/foundation/cli/commands/logs/__init__.py +1 -1
  6. provide/foundation/cli/commands/logs/query.py +1 -1
  7. provide/foundation/cli/commands/logs/send.py +1 -1
  8. provide/foundation/cli/commands/logs/tail.py +1 -1
  9. provide/foundation/cli/decorators.py +11 -10
  10. provide/foundation/cli/main.py +1 -1
  11. provide/foundation/cli/testing.py +2 -35
  12. provide/foundation/cli/utils.py +21 -17
  13. provide/foundation/config/__init__.py +35 -2
  14. provide/foundation/config/converters.py +479 -0
  15. provide/foundation/config/defaults.py +67 -0
  16. provide/foundation/config/env.py +4 -19
  17. provide/foundation/config/loader.py +9 -3
  18. provide/foundation/console/input.py +5 -5
  19. provide/foundation/console/output.py +35 -13
  20. provide/foundation/context/__init__.py +8 -4
  21. provide/foundation/context/core.py +85 -109
  22. provide/foundation/crypto/certificates/operations.py +1 -1
  23. provide/foundation/errors/__init__.py +2 -3
  24. provide/foundation/errors/decorators.py +0 -231
  25. provide/foundation/errors/types.py +0 -97
  26. provide/foundation/file/directory.py +13 -22
  27. provide/foundation/file/lock.py +3 -1
  28. provide/foundation/hub/components.py +72 -384
  29. provide/foundation/hub/config.py +151 -0
  30. provide/foundation/hub/discovery.py +62 -0
  31. provide/foundation/hub/handlers.py +81 -0
  32. provide/foundation/hub/lifecycle.py +194 -0
  33. provide/foundation/hub/manager.py +4 -4
  34. provide/foundation/hub/processors.py +44 -0
  35. provide/foundation/integrations/__init__.py +11 -0
  36. provide/foundation/{observability → integrations}/openobserve/__init__.py +10 -7
  37. provide/foundation/{observability → integrations}/openobserve/auth.py +1 -1
  38. provide/foundation/{observability → integrations}/openobserve/client.py +12 -12
  39. provide/foundation/{observability → integrations}/openobserve/commands.py +3 -3
  40. provide/foundation/integrations/openobserve/config.py +37 -0
  41. provide/foundation/{observability → integrations}/openobserve/formatters.py +1 -1
  42. provide/foundation/{observability → integrations}/openobserve/otlp.py +1 -1
  43. provide/foundation/{observability → integrations}/openobserve/search.py +2 -2
  44. provide/foundation/{observability → integrations}/openobserve/streaming.py +4 -4
  45. provide/foundation/logger/config/logging.py +68 -298
  46. provide/foundation/logger/config/telemetry.py +41 -121
  47. provide/foundation/logger/setup/coordinator.py +1 -1
  48. provide/foundation/observability/__init__.py +2 -2
  49. provide/foundation/process/__init__.py +9 -0
  50. provide/foundation/process/exit.py +47 -0
  51. provide/foundation/process/lifecycle.py +33 -33
  52. provide/foundation/resilience/__init__.py +35 -0
  53. provide/foundation/resilience/circuit.py +164 -0
  54. provide/foundation/resilience/decorators.py +220 -0
  55. provide/foundation/resilience/fallback.py +193 -0
  56. provide/foundation/resilience/retry.py +325 -0
  57. provide/foundation/streams/config.py +79 -0
  58. provide/foundation/streams/console.py +7 -8
  59. provide/foundation/streams/core.py +6 -3
  60. provide/foundation/streams/file.py +12 -2
  61. provide/foundation/testing/__init__.py +7 -2
  62. provide/foundation/testing/cli.py +30 -17
  63. provide/foundation/testing/common/__init__.py +0 -2
  64. provide/foundation/testing/common/fixtures.py +0 -27
  65. provide/foundation/testing/file/content_fixtures.py +316 -0
  66. provide/foundation/testing/file/directory_fixtures.py +107 -0
  67. provide/foundation/testing/file/fixtures.py +45 -516
  68. provide/foundation/testing/file/special_fixtures.py +153 -0
  69. provide/foundation/testing/logger.py +76 -0
  70. provide/foundation/testing/process/async_fixtures.py +405 -0
  71. provide/foundation/testing/process/fixtures.py +50 -571
  72. provide/foundation/testing/process/subprocess_fixtures.py +209 -0
  73. provide/foundation/testing/threading/basic_fixtures.py +101 -0
  74. provide/foundation/testing/threading/data_fixtures.py +99 -0
  75. provide/foundation/testing/threading/execution_fixtures.py +263 -0
  76. provide/foundation/testing/threading/fixtures.py +34 -500
  77. provide/foundation/testing/threading/sync_fixtures.py +97 -0
  78. provide/foundation/testing/time/fixtures.py +4 -4
  79. provide/foundation/tools/cache.py +8 -6
  80. provide/foundation/tools/downloader.py +23 -12
  81. provide/foundation/tracer/spans.py +2 -2
  82. provide/foundation/transport/config.py +26 -95
  83. provide/foundation/transport/middleware.py +30 -36
  84. provide/foundation/utils/deps.py +14 -12
  85. provide/foundation/utils/parsing.py +49 -4
  86. {provide_foundation-0.0.0.dev1.dist-info → provide_foundation-0.0.0.dev2.dist-info}/METADATA +1 -1
  87. {provide_foundation-0.0.0.dev1.dist-info → provide_foundation-0.0.0.dev2.dist-info}/RECORD +93 -68
  88. /provide/foundation/{observability → integrations}/openobserve/exceptions.py +0 -0
  89. /provide/foundation/{observability → integrations}/openobserve/models.py +0 -0
  90. {provide_foundation-0.0.0.dev1.dist-info → provide_foundation-0.0.0.dev2.dist-info}/WHEEL +0 -0
  91. {provide_foundation-0.0.0.dev1.dist-info → provide_foundation-0.0.0.dev2.dist-info}/entry_points.txt +0 -0
  92. {provide_foundation-0.0.0.dev1.dist-info → provide_foundation-0.0.0.dev2.dist-info}/licenses/LICENSE +0 -0
  93. {provide_foundation-0.0.0.dev1.dist-info → provide_foundation-0.0.0.dev2.dist-info}/top_level.txt +0 -0
@@ -1,523 +1,52 @@
1
1
  """
2
2
  File and Directory Test Fixtures.
3
3
 
4
+ Core file testing fixtures with re-exports from specialized modules.
4
5
  Common fixtures for testing file operations, creating temporary directories,
5
6
  and standard test file structures used across the provide-io ecosystem.
6
7
  """
7
8
 
8
- import tempfile
9
- from pathlib import Path
10
- from collections.abc import Generator
11
-
12
- import pytest
13
-
14
-
15
- @pytest.fixture
16
- def temp_directory() -> Generator[Path, None, None]:
17
- """
18
- Create a temporary directory that's cleaned up after test.
19
-
20
- Yields:
21
- Path to the temporary directory.
22
- """
23
- with tempfile.TemporaryDirectory() as temp_dir:
24
- yield Path(temp_dir)
25
-
26
-
27
- @pytest.fixture
28
- def test_files_structure() -> Generator[tuple[Path, Path], None, None]:
29
- """
30
- Create standard test file structure with files and subdirectories.
31
-
32
- Creates:
33
- - source/
34
- - file1.txt (contains "Content 1")
35
- - file2.txt (contains "Content 2")
36
- - subdir/
37
- - file3.txt (contains "Content 3")
38
-
39
- Yields:
40
- Tuple of (temp_path, source_path)
41
- """
42
- with tempfile.TemporaryDirectory() as temp_dir:
43
- path = Path(temp_dir)
44
- source = path / "source"
45
- source.mkdir()
46
-
47
- # Create test files
48
- (source / "file1.txt").write_text("Content 1")
49
- (source / "file2.txt").write_text("Content 2")
50
-
51
- # Create subdirectory with files
52
- subdir = source / "subdir"
53
- subdir.mkdir()
54
- (subdir / "file3.txt").write_text("Content 3")
55
-
56
- yield path, source
57
-
58
-
59
- @pytest.fixture
60
- def temp_file():
61
- """
62
- Create a temporary file factory with optional content.
63
-
64
- Returns:
65
- A function that creates temporary files with specified content and suffix.
66
- """
67
- created_files = []
68
-
69
- def _make_temp_file(content: str = "test content", suffix: str = ".txt") -> Path:
70
- """
71
- Create a temporary file.
72
-
73
- Args:
74
- content: Content to write to the file
75
- suffix: File suffix/extension
76
-
77
- Returns:
78
- Path to the created temporary file
79
- """
80
- with tempfile.NamedTemporaryFile(mode='w', suffix=suffix, delete=False) as f:
81
- f.write(content)
82
- path = Path(f.name)
83
- created_files.append(path)
84
- return path
85
-
86
- yield _make_temp_file
87
-
88
- # Cleanup all created files
89
- for path in created_files:
90
- path.unlink(missing_ok=True)
91
-
92
-
93
- @pytest.fixture
94
- def binary_file() -> Generator[Path, None, None]:
95
- """
96
- Create a temporary binary file for testing.
97
-
98
- Yields:
99
- Path to a binary file containing sample binary data.
100
- """
101
- with tempfile.NamedTemporaryFile(mode='wb', suffix='.bin', delete=False) as f:
102
- # Write some binary data
103
- f.write(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09')
104
- f.write(b'\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8\xF7\xF6')
105
- path = Path(f.name)
106
-
107
- yield path
108
- path.unlink(missing_ok=True)
109
-
110
-
111
- @pytest.fixture
112
- def nested_directory_structure() -> Generator[Path, None, None]:
113
- """
114
- Create a deeply nested directory structure for testing.
115
-
116
- Creates:
117
- - level1/
118
- - level2/
119
- - level3/
120
- - deep_file.txt
121
- - file_l2.txt
122
- - file_l1.txt
123
-
124
- Yields:
125
- Path to the root of the structure.
126
- """
127
- with tempfile.TemporaryDirectory() as temp_dir:
128
- root = Path(temp_dir)
129
-
130
- # Create nested structure
131
- deep_dir = root / "level1" / "level2" / "level3"
132
- deep_dir.mkdir(parents=True)
133
-
134
- # Add files at different levels
135
- (root / "file_l1.txt").write_text("Level 1 file")
136
- (root / "level1" / "file_l2.txt").write_text("Level 2 file")
137
- (deep_dir / "deep_file.txt").write_text("Deep file")
138
-
139
- yield root
140
-
141
-
142
- @pytest.fixture
143
- def empty_directory() -> Generator[Path, None, None]:
144
- """
145
- Create an empty temporary directory.
146
-
147
- Yields:
148
- Path to an empty directory.
149
- """
150
- with tempfile.TemporaryDirectory() as temp_dir:
151
- yield Path(temp_dir)
152
-
153
-
154
- @pytest.fixture
155
- def readonly_file() -> Generator[Path, None, None]:
156
- """
157
- Create a read-only file for permission testing.
158
-
159
- Yields:
160
- Path to a read-only file.
161
- """
162
- with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False) as f:
163
- f.write("Read-only content")
164
- path = Path(f.name)
165
-
166
- # Make file read-only
167
- path.chmod(0o444)
168
-
169
- yield path
170
-
171
- # Restore write permission for cleanup
172
- path.chmod(0o644)
173
- path.unlink(missing_ok=True)
174
-
175
-
176
- @pytest.fixture
177
- def temp_named_file():
178
- """
179
- Create a named temporary file factory.
180
-
181
- Returns:
182
- Function that creates named temporary files.
183
- """
184
- created_files = []
185
-
186
- def _make_named_file(
187
- content: bytes | str = None,
188
- suffix: str = "",
189
- prefix: str = "tmp",
190
- dir: Path | str = None,
191
- mode: str = 'w+b',
192
- delete: bool = False
193
- ) -> Path:
194
- """
195
- Create a named temporary file.
196
-
197
- Args:
198
- content: Optional content to write
199
- suffix: File suffix
200
- prefix: File prefix
201
- dir: Directory for the file
202
- mode: File mode
203
- delete: Whether to delete on close
204
-
205
- Returns:
206
- Path to the created file
207
- """
208
- if isinstance(dir, Path):
209
- dir = str(dir)
210
-
211
- f = tempfile.NamedTemporaryFile(
212
- mode=mode,
213
- suffix=suffix,
214
- prefix=prefix,
215
- dir=dir,
216
- delete=delete
217
- )
218
-
219
- if content is not None:
220
- if isinstance(content, str):
221
- if 'b' in mode:
222
- f.write(content.encode())
223
- else:
224
- f.write(content)
225
- else:
226
- f.write(content)
227
- f.flush()
228
-
229
- path = Path(f.name)
230
- f.close()
231
-
232
- if not delete:
233
- created_files.append(path)
234
-
235
- return path
236
-
237
- yield _make_named_file
238
-
239
- # Cleanup
240
- for path in created_files:
241
- path.unlink(missing_ok=True)
242
-
243
-
244
- @pytest.fixture
245
- def temp_file_with_content():
246
- """
247
- Create temporary files with specific content.
248
-
249
- Returns:
250
- Function that creates files with content.
251
- """
252
- created_files = []
253
-
254
- def _make_file(
255
- content: str | bytes,
256
- suffix: str = ".txt",
257
- encoding: str = "utf-8"
258
- ) -> Path:
259
- """
260
- Create a temporary file with content.
261
-
262
- Args:
263
- content: Content to write
264
- suffix: File suffix
265
- encoding: Text encoding (for str content)
266
-
267
- Returns:
268
- Path to created file
269
- """
270
- with tempfile.NamedTemporaryFile(
271
- mode='wb' if isinstance(content, bytes) else 'w',
272
- suffix=suffix,
273
- delete=False,
274
- encoding=None if isinstance(content, bytes) else encoding
275
- ) as f:
276
- f.write(content)
277
- path = Path(f.name)
278
-
279
- created_files.append(path)
280
- return path
281
-
282
- yield _make_file
283
-
284
- # Cleanup
285
- for path in created_files:
286
- path.unlink(missing_ok=True)
287
-
288
-
289
- @pytest.fixture
290
- def temp_binary_file():
291
- """
292
- Create temporary binary files.
293
-
294
- Returns:
295
- Function that creates binary files.
296
- """
297
- created_files = []
298
-
299
- def _make_binary(
300
- size: int = 1024,
301
- pattern: bytes = None,
302
- suffix: str = ".bin"
303
- ) -> Path:
304
- """
305
- Create a temporary binary file.
306
-
307
- Args:
308
- size: File size in bytes
309
- pattern: Optional byte pattern to repeat
310
- suffix: File suffix
311
-
312
- Returns:
313
- Path to created binary file
314
- """
315
- if pattern is None:
316
- # Create pseudo-random binary data
317
- import random
318
- content = bytes(random.randint(0, 255) for _ in range(size))
319
- else:
320
- # Repeat pattern to reach size
321
- repetitions = size // len(pattern) + 1
322
- content = (pattern * repetitions)[:size]
323
-
324
- with tempfile.NamedTemporaryFile(
325
- mode='wb',
326
- suffix=suffix,
327
- delete=False
328
- ) as f:
329
- f.write(content)
330
- path = Path(f.name)
331
-
332
- created_files.append(path)
333
- return path
334
-
335
- yield _make_binary
336
-
337
- # Cleanup
338
- for path in created_files:
339
- path.unlink(missing_ok=True)
340
-
341
-
342
- @pytest.fixture
343
- def temp_csv_file():
344
- """
345
- Create temporary CSV files for testing.
346
-
347
- Returns:
348
- Function that creates CSV files.
349
- """
350
- import csv
351
- created_files = []
352
-
353
- def _make_csv(
354
- headers: list[str],
355
- rows: list[list],
356
- suffix: str = ".csv"
357
- ) -> Path:
358
- """
359
- Create a temporary CSV file.
360
-
361
- Args:
362
- headers: Column headers
363
- rows: Data rows
364
- suffix: File suffix
365
-
366
- Returns:
367
- Path to created CSV file
368
- """
369
- with tempfile.NamedTemporaryFile(
370
- mode='w',
371
- suffix=suffix,
372
- delete=False,
373
- newline=''
374
- ) as f:
375
- writer = csv.writer(f)
376
- writer.writerow(headers)
377
- writer.writerows(rows)
378
- path = Path(f.name)
379
-
380
- created_files.append(path)
381
- return path
382
-
383
- yield _make_csv
384
-
385
- # Cleanup
386
- for path in created_files:
387
- path.unlink(missing_ok=True)
388
-
389
-
390
- @pytest.fixture
391
- def temp_json_file():
392
- """
393
- Create temporary JSON files for testing.
394
-
395
- Returns:
396
- Function that creates JSON files.
397
- """
398
- import json
399
- created_files = []
400
-
401
- def _make_json(
402
- data: dict | list,
403
- suffix: str = ".json",
404
- indent: int = 2
405
- ) -> Path:
406
- """
407
- Create a temporary JSON file.
408
-
409
- Args:
410
- data: JSON data to write
411
- suffix: File suffix
412
- indent: JSON indentation
413
-
414
- Returns:
415
- Path to created JSON file
416
- """
417
- with tempfile.NamedTemporaryFile(
418
- mode='w',
419
- suffix=suffix,
420
- delete=False
421
- ) as f:
422
- json.dump(data, f, indent=indent)
423
- path = Path(f.name)
424
-
425
- created_files.append(path)
426
- return path
427
-
428
- yield _make_json
429
-
430
- # Cleanup
431
- for path in created_files:
432
- path.unlink(missing_ok=True)
433
-
434
-
435
- @pytest.fixture
436
- def temp_symlink():
437
- """
438
- Create temporary symbolic links for testing.
439
-
440
- Returns:
441
- Function that creates symbolic links.
442
- """
443
- created_links = []
444
-
445
- def _make_symlink(
446
- target: Path | str,
447
- link_name: Path | str = None
448
- ) -> Path:
449
- """
450
- Create a temporary symbolic link.
451
-
452
- Args:
453
- target: Target path for the symlink
454
- link_name: Optional link name (auto-generated if None)
455
-
456
- Returns:
457
- Path to created symlink
458
- """
459
- target = Path(target)
460
-
461
- if link_name is None:
462
- with tempfile.NamedTemporaryFile(delete=True) as f:
463
- link_name = Path(f.name + "_link")
464
- else:
465
- link_name = Path(link_name)
466
-
467
- link_name.symlink_to(target)
468
- created_links.append(link_name)
469
-
470
- return link_name
471
-
472
- yield _make_symlink
473
-
474
- # Cleanup
475
- for link in created_links:
476
- link.unlink(missing_ok=True)
477
-
478
-
479
- @pytest.fixture
480
- def temp_executable_file():
481
- """
482
- Create temporary executable files for testing.
483
-
484
- Returns:
485
- Function that creates executable files.
486
- """
487
- import stat
488
- created_files = []
489
-
490
- def _make_executable(
491
- content: str = "#!/bin/sh\necho 'test'\n",
492
- suffix: str = ".sh"
493
- ) -> Path:
494
- """
495
- Create a temporary executable file.
496
-
497
- Args:
498
- content: Script content
499
- suffix: File suffix
500
-
501
- Returns:
502
- Path to created executable file
503
- """
504
- with tempfile.NamedTemporaryFile(
505
- mode='w',
506
- suffix=suffix,
507
- delete=False
508
- ) as f:
509
- f.write(content)
510
- path = Path(f.name)
511
-
512
- # Make executable
513
- current = path.stat().st_mode
514
- path.chmod(current | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
515
-
516
- created_files.append(path)
517
- return path
518
-
519
- yield _make_executable
520
-
521
- # Cleanup
522
- for path in created_files:
523
- path.unlink(missing_ok=True)
9
+ # Re-export all fixtures from specialized modules
10
+ from provide.foundation.testing.file.directory_fixtures import (
11
+ temp_directory,
12
+ test_files_structure,
13
+ nested_directory_structure,
14
+ empty_directory,
15
+ )
16
+
17
+ from provide.foundation.testing.file.special_fixtures import (
18
+ binary_file,
19
+ readonly_file,
20
+ temp_symlink,
21
+ temp_executable_file,
22
+ )
23
+
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
+ __all__ = [
35
+ # Directory fixtures
36
+ "temp_directory",
37
+ "test_files_structure",
38
+ "nested_directory_structure",
39
+ "empty_directory",
40
+ # Special file fixtures
41
+ "binary_file",
42
+ "readonly_file",
43
+ "temp_symlink",
44
+ "temp_executable_file",
45
+ # Content-based fixtures
46
+ "temp_file",
47
+ "temp_named_file",
48
+ "temp_file_with_content",
49
+ "temp_binary_file",
50
+ "temp_csv_file",
51
+ "temp_json_file",
52
+ ]
@@ -0,0 +1,153 @@
1
+ """
2
+ Special file test fixtures.
3
+
4
+ Fixtures for creating specialized files like binary files, read-only files,
5
+ symbolic links, and executable files.
6
+ """
7
+
8
+ import stat
9
+ import tempfile
10
+ from pathlib import Path
11
+ from collections.abc import Generator
12
+
13
+ import pytest
14
+
15
+ from provide.foundation.file.safe import safe_delete
16
+
17
+
18
+ @pytest.fixture
19
+ def binary_file() -> Generator[Path, None, None]:
20
+ """
21
+ Create a temporary binary file for testing.
22
+
23
+ Yields:
24
+ Path to a binary file containing sample binary data.
25
+ """
26
+ with tempfile.NamedTemporaryFile(mode='wb', suffix='.bin', delete=False) as f:
27
+ # Write some binary data
28
+ f.write(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09')
29
+ f.write(b'\xFF\xFE\xFD\xFC\xFB\xFA\xF9\xF8\xF7\xF6')
30
+ path = Path(f.name)
31
+
32
+ yield path
33
+ safe_delete(path, missing_ok=True)
34
+
35
+
36
+ @pytest.fixture
37
+ def readonly_file() -> Generator[Path, None, None]:
38
+ """
39
+ Create a read-only file for permission testing.
40
+
41
+ Yields:
42
+ Path to a read-only file.
43
+ """
44
+ with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False) as f:
45
+ f.write("Read-only content")
46
+ path = Path(f.name)
47
+
48
+ # Make file read-only
49
+ path.chmod(0o444)
50
+
51
+ yield path
52
+
53
+ # Restore write permission for cleanup
54
+ path.chmod(0o644)
55
+ safe_delete(path, missing_ok=True)
56
+
57
+
58
+ @pytest.fixture
59
+ def temp_symlink():
60
+ """
61
+ Create temporary symbolic links for testing.
62
+
63
+ Returns:
64
+ Function that creates symbolic links.
65
+ """
66
+ created_links = []
67
+
68
+ def _make_symlink(
69
+ target: Path | str,
70
+ link_name: Path | str = None
71
+ ) -> Path:
72
+ """
73
+ Create a temporary symbolic link.
74
+
75
+ Args:
76
+ target: Target path for the symlink
77
+ link_name: Optional link name (auto-generated if None)
78
+
79
+ Returns:
80
+ Path to created symlink
81
+ """
82
+ target = Path(target)
83
+
84
+ if link_name is None:
85
+ with tempfile.NamedTemporaryFile(delete=True) as f:
86
+ link_name = Path(f.name + "_link")
87
+ else:
88
+ link_name = Path(link_name)
89
+
90
+ link_name.symlink_to(target)
91
+ created_links.append(link_name)
92
+
93
+ return link_name
94
+
95
+ yield _make_symlink
96
+
97
+ # Cleanup
98
+ for link in created_links:
99
+ safe_delete(link, missing_ok=True)
100
+
101
+
102
+ @pytest.fixture
103
+ def temp_executable_file():
104
+ """
105
+ Create temporary executable files for testing.
106
+
107
+ Returns:
108
+ Function that creates executable files.
109
+ """
110
+ created_files = []
111
+
112
+ def _make_executable(
113
+ content: str = "#!/bin/sh\necho 'test'\n",
114
+ suffix: str = ".sh"
115
+ ) -> Path:
116
+ """
117
+ Create a temporary executable file.
118
+
119
+ Args:
120
+ content: Script content
121
+ suffix: File suffix
122
+
123
+ Returns:
124
+ Path to created executable file
125
+ """
126
+ with tempfile.NamedTemporaryFile(
127
+ mode='w',
128
+ suffix=suffix,
129
+ delete=False
130
+ ) as f:
131
+ f.write(content)
132
+ path = Path(f.name)
133
+
134
+ # Make executable
135
+ current = path.stat().st_mode
136
+ path.chmod(current | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
137
+
138
+ created_files.append(path)
139
+ return path
140
+
141
+ yield _make_executable
142
+
143
+ # Cleanup
144
+ for path in created_files:
145
+ safe_delete(path, missing_ok=True)
146
+
147
+
148
+ __all__ = [
149
+ "binary_file",
150
+ "readonly_file",
151
+ "temp_symlink",
152
+ "temp_executable_file",
153
+ ]