Skip to content

Commit

Permalink
Use a counter for data for shorter file paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jayqi committed Jan 6, 2024
1 parent db52298 commit f38e944
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit f38e944

Please sign in to comment.