feat(phase1): add image storage utilities
- Create backend/services/image_storage.py with 4 core functions:
- sanitize_filename(): remove unsafe chars, limit to 255 chars, convert to lowercase
- get_unique_filename(): handle collisions with UUID suffix (format: {name}_{uuid8}_{variant}.jpg)
- ensure_image_directories(): create /images/ root and category subdirs on startup
- save_image(): save bytes to /images/{category}/{filename}, returns relative path
- Create comprehensive test suite (22 tests) covering all functionality
- Integrate ensure_image_directories() into FastAPI startup event
- Directory structure: /images/{category}/{filename}
- Collision handling: auto-suffix with UUID if filename exists
- All tests passing, pathlib.Path for safe operations
This commit is contained in:
24
venv/lib/python3.12/site-packages/_pytest/tracemalloc.py
Normal file
24
venv/lib/python3.12/site-packages/_pytest/tracemalloc.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def tracemalloc_message(source: object) -> str:
|
||||
if source is None:
|
||||
return ""
|
||||
|
||||
try:
|
||||
import tracemalloc
|
||||
except ImportError:
|
||||
return ""
|
||||
|
||||
tb = tracemalloc.get_object_traceback(source)
|
||||
if tb is not None:
|
||||
formatted_tb = "\n".join(tb.format())
|
||||
# Use a leading new line to better separate the (large) output
|
||||
# from the traceback to the previous warning text.
|
||||
return f"\nObject allocated at:\n{formatted_tb}"
|
||||
# No need for a leading new line.
|
||||
url = "https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings"
|
||||
return (
|
||||
"Enable tracemalloc to get traceback where the object was allocated.\n"
|
||||
f"See {url} for more info."
|
||||
)
|
||||
Reference in New Issue
Block a user