mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-06 22:51:18 +08:00
chore: improve ComfyUI maintenance path
This commit is contained in:
parent
0cce76d402
commit
ccc841af36
22
tests-unit/compare_test/conftest_test.py
Normal file
22
tests-unit/compare_test/conftest_test.py
Normal file
@ -0,0 +1,22 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.compare.conftest import gather_file_basenames
|
||||
|
||||
|
||||
class TestGatherFileBasenames:
|
||||
def test_returns_png_basenames(self):
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
open(os.path.join(tmpdir, "a.png"), "w").close()
|
||||
open(os.path.join(tmpdir, "b.txt"), "w").close()
|
||||
open(os.path.join(tmpdir, "c.png"), "w").close()
|
||||
assert sorted(gather_file_basenames(tmpdir)) == ["a.png", "c.png"]
|
||||
|
||||
def test_missing_directory_returns_empty_list(self):
|
||||
assert gather_file_basenames("/nonexistent/path/12345") == []
|
||||
|
||||
def test_non_string_input_raises(self):
|
||||
with pytest.raises(AssertionError):
|
||||
gather_file_basenames(123) # type: ignore[arg-type]
|
||||
@ -27,12 +27,11 @@ def args_pytest(pytestconfig):
|
||||
return args
|
||||
|
||||
|
||||
def gather_file_basenames(directory: str):
|
||||
files = []
|
||||
for file in os.listdir(directory):
|
||||
if file.endswith(".png"):
|
||||
files.append(file)
|
||||
return files
|
||||
def gather_file_basenames(directory: str) -> list[str]:
|
||||
assert isinstance(directory, str), f"directory must be str, got {type(directory).__name__}"
|
||||
if not os.path.isdir(directory):
|
||||
return []
|
||||
return [file for file in os.listdir(directory) if file.endswith(".png")]
|
||||
|
||||
# Creates the list of baseline file names to use as a fixture
|
||||
def pytest_generate_tests(metafunc):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user