mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-10 16:37:36 +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
|
return args
|
||||||
|
|
||||||
|
|
||||||
def gather_file_basenames(directory: str):
|
def gather_file_basenames(directory: str) -> list[str]:
|
||||||
files = []
|
assert isinstance(directory, str), f"directory must be str, got {type(directory).__name__}"
|
||||||
for file in os.listdir(directory):
|
if not os.path.isdir(directory):
|
||||||
if file.endswith(".png"):
|
return []
|
||||||
files.append(file)
|
return [file for file in os.listdir(directory) if file.endswith(".png")]
|
||||||
return files
|
|
||||||
|
|
||||||
# Creates the list of baseline file names to use as a fixture
|
# Creates the list of baseline file names to use as a fixture
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user