From f38e94448dcd0366520bab4b31ad0928f44b1c82 Mon Sep 17 00:00:00 2001 From: Jay Qi Date: Fri, 5 Jan 2024 23:29:02 -0500 Subject: [PATCH] Use a counter for data for shorter file paths --- tests/utils.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 4d88fa2..fb19142 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,13 +1,24 @@ import hashlib from pathlib import Path from tempfile import TemporaryDirectory +from typing import Any import uuid from zipfile import ZipFile -def data_factory() -> str: - """Utility function to generate a random data string.""" - return str(uuid.uuid4()) +class _DataFactory: + """Utility function to generate a unique data string using an incrementing counter.""" + + def __init__(self) -> None: + self.counter = 0 + + def __call__(self) -> str: + out = f"{self.counter:04d}:" + self.counter += 1 + return out + + +data_factory = _DataFactory() def file_factory(parent_dir: Path) -> Path: