From 4295769a488fad59e61907c5c324a0a9e4e84e4d Mon Sep 17 00:00:00 2001 From: telamonian Date: Mon, 12 Aug 2024 22:58:59 -0400 Subject: [PATCH] added `assert` to `test_compile`. Might still be a bit fragile --- .../mock_requirements/requirements.compiled | 20 +++++++++++++++++++ tests/uv/test_uv.py | 15 ++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 tests/uv/mock_requirements/requirements.compiled diff --git a/tests/uv/mock_requirements/requirements.compiled b/tests/uv/mock_requirements/requirements.compiled new file mode 100644 index 0000000..70d906c --- /dev/null +++ b/tests/uv/mock_requirements/requirements.compiled @@ -0,0 +1,20 @@ +# This file was autogenerated by uv via the following command: +# uv pip compile /home/tel/git/comfy-cli/tests/uv/mock_requirements/core_reqs.txt /home/tel/git/comfy-cli/tests/uv/mock_requirements/x_reqs.txt /home/tel/git/comfy-cli/tests/uv/mock_requirements/y_reqs.txt --index-strategy unsafe-best-match --override /home/tel/git/comfy-cli/tests/temp/test_uv/override.txt -o /home/tel/git/comfy-cli/tests/temp/test_uv/requirements.compiled +mpmath==1.3.0 + # via sympy +numpy==2.0.1 + # via + # --override override.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/x_reqs.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/y_reqs.txt +sympy==1.13.2 + # via + # --override override.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/x_reqs.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/y_reqs.txt +tqdm==4.66.4 + # via + # --override override.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/core_reqs.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/x_reqs.txt + # -r /home/tel/git/comfy-cli/tests/uv/mock_requirements/y_reqs.txt diff --git a/tests/uv/test_uv.py b/tests/uv/test_uv.py index 205c5af..99b7d32 100644 --- a/tests/uv/test_uv.py +++ b/tests/uv/test_uv.py @@ -1,4 +1,3 @@ -from itertools import cycle from pathlib import Path import pytest import shutil @@ -7,8 +6,11 @@ from comfy_cli import ui hereDir = Path(__file__).parent.resolve() +reqsDir = hereDir/"mock_requirements" + +# set up a temp dir to write files to testsDir = hereDir.parent.resolve() -temp = testsDir / "temp" / "test_uv" +temp = testsDir/"temp"/"test_uv" shutil.rmtree(temp, ignore_errors=True) temp.mkdir(exist_ok=True, parents=True) @@ -23,12 +25,13 @@ def _mock_prompt_select(*args, **kwargs): def test_compile(mock_prompt_select): depComp = DependencyCompiler( cwd=temp, - reqFilesCore=[hereDir/"mock_requirements/core_reqs.txt"], - reqFilesExt=[hereDir/"mock_requirements/x_reqs.txt", hereDir/"mock_requirements/y_reqs.txt"], + reqFilesCore=[reqsDir/"core_reqs.txt"], + reqFilesExt=[reqsDir/"x_reqs.txt", reqsDir/"y_reqs.txt"], ) depComp.makeOverride() depComp.compileCorePlusExt() -if __name__ == "__main__": - test_compile() + with open(reqsDir/"requirements.compiled", "r") as known, open(temp/"requirements.compiled", "r") as test: + knownLines, testLines = known.readlines(), test.readlines() + assert knownLines == testLines