Files
AnyImage/tests/test_pack.py
nan a503786c62 Refactor and enhance SnapForm functionality
- Introduced MODEL_NUMBERS for better model indexing.
- Improved enum_items function to cache results and handle download status.
- Updated ActiveJob class to manage temporary input paths and added displacement_via property.
- Changed IMAGE_DEPTH_PROCESS_RES_METHOD from "lower_bound_resize" to "upper_bound_resize".
- Enhanced RunJob operator to include new properties and improved error messages.
- Modified panel layout for better user experience and added runtime installation checks.
- Updated SnapFormSettings to reflect new model properties and defaults.
- Added temporary input path management in runtime.
- Refined worker functions to improve error handling and messaging.
- Expanded tests to cover new functionality and ensure backward compatibility.
- Fixed packaging script to align with versioning conventions.
2026-08-03 13:47:15 +08:00

43 lines
1.3 KiB
Python

import importlib.util
import tempfile
import unittest
from pathlib import Path
from zipfile import ZipFile
PROJECT_ROOT = Path(__file__).resolve().parents[1]
def load_pack():
specification = importlib.util.spec_from_file_location(
"snapform_pack",
PROJECT_ROOT / "pack.py",
)
module = importlib.util.module_from_spec(specification)
specification.loader.exec_module(module)
return module
class PackTest(unittest.TestCase):
def test_builds_extension_root_layout(self):
pack = load_pack()
with tempfile.TemporaryDirectory() as directory:
original_dist = pack.DIST_DIR
pack.DIST_DIR = Path(directory)
try:
output_path = pack.build_extension()
finally:
pack.DIST_DIR = original_dist
self.assertEqual(output_path.name, "SnapForm.v0.9.27.zip")
with ZipFile(output_path) as archive:
names = set(archive.namelist())
self.assertIn("__init__.py", names)
self.assertIn("blender_manifest.toml", names)
self.assertIn("image_depth.py", names)
self.assertNotIn("snapform_depth_plane.py", names)
self.assertIn("worker.py", names)
self.assertNotIn("importer.py", names)
self.assertNotIn("snapform/__init__.py", names)