tenzir-test 0.9.4__py3-none-any.whl → 0.9.5__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.
tenzir_test/run.py CHANGED
@@ -349,6 +349,7 @@ _TMP_ROOT_NAME = ".tenzir-test"
349
349
  _TMP_SUBDIR_NAME = "tmp"
350
350
  _TMP_BASE_DIRS: set[Path] = set()
351
351
  _ACTIVE_TMP_DIRS: set[Path] = set()
352
+ _TMP_DIR_LOCK = threading.Lock()
352
353
  KEEP_TMP_DIRS = bool(os.environ.get(_TMP_KEEP_ENV_VAR))
353
354
 
354
355
  SHOW_DIFF_OUTPUT = True
@@ -506,10 +507,13 @@ def _tmp_prefix_for(test: Path) -> str:
506
507
 
507
508
 
508
509
  def _create_test_tmp_dir(test: Path) -> Path:
509
- base = _resolve_tmp_base()
510
510
  prefix = f"{_tmp_prefix_for(test)}-"
511
- path = Path(tempfile.mkdtemp(prefix=prefix, dir=str(base)))
512
- _ACTIVE_TMP_DIRS.add(path)
511
+ with _TMP_DIR_LOCK:
512
+ base = _resolve_tmp_base()
513
+ if not base.exists():
514
+ base.mkdir(parents=True, exist_ok=True)
515
+ path = Path(tempfile.mkdtemp(prefix=prefix, dir=str(base)))
516
+ _ACTIVE_TMP_DIRS.add(path)
513
517
  return path
514
518
 
515
519
 
@@ -522,22 +526,27 @@ def cleanup_test_tmp_dir(path: str | os.PathLike[str] | None) -> None:
522
526
  if not path:
523
527
  return
524
528
  tmp_path = Path(path)
525
- _ACTIVE_TMP_DIRS.discard(tmp_path)
529
+ with _TMP_DIR_LOCK:
530
+ _ACTIVE_TMP_DIRS.discard(tmp_path)
526
531
  try:
527
532
  fixtures_impl.invoke_tmp_dir_cleanup(tmp_path)
528
533
  except Exception: # pragma: no cover - defensive logging
529
534
  pass
530
535
  if KEEP_TMP_DIRS:
531
536
  return
532
- if tmp_path.exists():
533
- shutil.rmtree(tmp_path, ignore_errors=True)
534
- _cleanup_tmp_base_dirs()
537
+ with _TMP_DIR_LOCK:
538
+ if tmp_path.exists():
539
+ shutil.rmtree(tmp_path, ignore_errors=True)
540
+ _cleanup_tmp_base_dirs()
535
541
 
536
542
 
537
543
  def _cleanup_remaining_tmp_dirs() -> None:
538
- for tmp_path in list(_ACTIVE_TMP_DIRS):
544
+ with _TMP_DIR_LOCK:
545
+ remaining = list(_ACTIVE_TMP_DIRS)
546
+ for tmp_path in remaining:
539
547
  cleanup_test_tmp_dir(tmp_path)
540
- _cleanup_tmp_base_dirs()
548
+ with _TMP_DIR_LOCK:
549
+ _cleanup_tmp_base_dirs()
541
550
 
542
551
 
543
552
  def _cleanup_all_tmp_dirs() -> None:
@@ -545,9 +554,12 @@ def _cleanup_all_tmp_dirs() -> None:
545
554
 
546
555
  if KEEP_TMP_DIRS:
547
556
  return
548
- for tmp_path in list(_ACTIVE_TMP_DIRS):
557
+ with _TMP_DIR_LOCK:
558
+ remaining = list(_ACTIVE_TMP_DIRS)
559
+ for tmp_path in remaining:
549
560
  cleanup_test_tmp_dir(tmp_path)
550
- _cleanup_tmp_base_dirs()
561
+ with _TMP_DIR_LOCK:
562
+ _cleanup_tmp_base_dirs()
551
563
 
552
564
 
553
565
  def _cleanup_tmp_base_dirs() -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tenzir-test
3
- Version: 0.9.4
3
+ Version: 0.9.5
4
4
  Summary: Reusable test execution framework extracted from the Tenzir repository.
5
5
  Project-URL: Homepage, https://github.com/tenzir/test
6
6
  Project-URL: Repository, https://github.com/tenzir/test
@@ -55,36 +55,6 @@ uvx tenzir-test --help
55
55
  `uvx` downloads the newest compatible release, runs it in an isolated
56
56
  environment, and caches subsequent invocations for fast reuse.
57
57
 
58
- ## 🚀 Quick Start
59
-
60
- Create a project skeleton that mirrors the layout the harness expects:
61
-
62
- ```text
63
- project-root/
64
- ├── fixtures/
65
- │ └── http.py
66
- ├── inputs/
67
- │ └── sample.ndjson
68
- ├── runners/
69
- │ └── __init__.py
70
- └── tests/
71
- ├── alerts/
72
- │ ├── sample.py
73
- │ └── sample.txt
74
- └── regression/
75
- ├── dummy.tql
76
- └── dummy.txt
77
- ```
78
-
79
- 1. Author fixtures in `fixtures/` and register them at import time.
80
- 2. Store reusable datasets in `inputs/`—the harness exposes the path via
81
- `TENZIR_INPUTS` and provides a per-test scratch directory through
82
- `TENZIR_TMP_DIR` when tests execute.
83
- Use `--keep` (or `-k`) to preserve those temporary directories for debugging.
84
- 3. Create tests in `tests/` and pair them with reference artifacts (for example
85
- `.txt`) that the harness compares against.
86
- 4. Run `uvx tenzir-test` from the project root to execute the full suite.
87
-
88
58
  ## 📚 Documentation
89
59
 
90
60
  Consult our [user guide](https://docs.tenzir.com/guides/testing/write-tests)
@@ -5,7 +5,7 @@ tenzir_test/cli.py,sha256=O1FaxYFKWal--aqs-ZFT2URqL26_HjUtFNDACIBspXA,5452
5
5
  tenzir_test/config.py,sha256=q1_VEXuxL-xsGlnooeGvXxx9cMw652UEB9a1mPzZIQs,1680
6
6
  tenzir_test/packages.py,sha256=cTCQdGjCS1XmuKyiwh0ew-z9tHn6J-xZ6nvBP-hU8bc,948
7
7
  tenzir_test/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- tenzir_test/run.py,sha256=X5k81jdAV4f3eH4pMFq3_B0YW7JIqBwE3j2vK5UgK3s,115729
8
+ tenzir_test/run.py,sha256=K6ZTQktVBLRMHQfx8322cKQzZIqQACa1PPXHO25TQNQ,116108
9
9
  tenzir_test/engine/__init__.py,sha256=5APwy90YDm7rmL_qCZfToAcfbQthcZ8yV2_ExXKqaqE,110
10
10
  tenzir_test/engine/operations.py,sha256=OCYjuMHyMAaay4s08u2Sl7oE-PmgeXumylp7R8GYIH4,950
11
11
  tenzir_test/engine/registry.py,sha256=LXCr6TGlv1sR1m1eboTk7SrbS2IVErc3PqUuHxGA2xk,594
@@ -22,8 +22,8 @@ tenzir_test/runners/runner.py,sha256=LtlD8huQOSmD7RyYDnKeCuI4Y6vhxGXMKsHA2qgfWN0
22
22
  tenzir_test/runners/shell_runner.py,sha256=wLiHYGrZDHPof6hohDT-t6zEi8w-DlkR5QG0i5DpwWE,5892
23
23
  tenzir_test/runners/tenzir_runner.py,sha256=464FFYS_mh6l-ehccc-S8cIUO1MxdapwQL5X3PmMkMI,1006
24
24
  tenzir_test/runners/tql_runner.py,sha256=2ZLMf3TIKwcOvaOFrVvvhzK-EcWmGOUZxKkbSoByyQA,248
25
- tenzir_test-0.9.4.dist-info/METADATA,sha256=V6OEJxdUSsQnUR6osqMM9L_-WZAD2xa1VXjvNaHs_zI,3982
26
- tenzir_test-0.9.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
- tenzir_test-0.9.4.dist-info/entry_points.txt,sha256=q0eD9RQ_9eMPYvFNpBElo55HQYeaPgLfe9YhLsNwl10,93
28
- tenzir_test-0.9.4.dist-info/licenses/LICENSE,sha256=ajMbpcBiSTXI8Rr4t17pvowV-On8DktghfZKxY_A22Q,10750
29
- tenzir_test-0.9.4.dist-info/RECORD,,
25
+ tenzir_test-0.9.5.dist-info/METADATA,sha256=AFPYUhmvTIQ5XWmNBhmzTOb_2A_0gNu_kjWDc18LylQ,3007
26
+ tenzir_test-0.9.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
27
+ tenzir_test-0.9.5.dist-info/entry_points.txt,sha256=q0eD9RQ_9eMPYvFNpBElo55HQYeaPgLfe9YhLsNwl10,93
28
+ tenzir_test-0.9.5.dist-info/licenses/LICENSE,sha256=ajMbpcBiSTXI8Rr4t17pvowV-On8DktghfZKxY_A22Q,10750
29
+ tenzir_test-0.9.5.dist-info/RECORD,,