mirror of
https://github.com/lllyasviel/Fooocus.git
synced 2026-08-16 13:13:16 +02:00
docs: add instructions for running unittests on embedded python, code cleanup
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
## Running unit tests
|
## Running unit tests
|
||||||
|
|
||||||
|
Native python:
|
||||||
```
|
```
|
||||||
python -m unittest tests/
|
python -m unittest tests/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Embedded python (Windows zip file installation method):
|
||||||
|
```
|
||||||
|
..\python_embeded\python.exe -m unittest
|
||||||
|
```
|
||||||
|
|||||||
+5
-5
@@ -1,10 +1,10 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from modules import util
|
from modules import util
|
||||||
|
|
||||||
|
|
||||||
class TestUtils(unittest.TestCase):
|
class TestUtils(unittest.TestCase):
|
||||||
def test_can_parse_tokens_with_lora(self):
|
def test_can_parse_tokens_with_lora(self):
|
||||||
|
|
||||||
test_cases = [
|
test_cases = [
|
||||||
{
|
{
|
||||||
"input": ("some prompt, very cool, <lora:hey-lora:0.4>, cool <lora:you-lora:0.2>", [], 5),
|
"input": ("some prompt, very cool, <lora:hey-lora:0.4>, cool <lora:you-lora:0.2>", [], 5),
|
||||||
@@ -36,13 +36,13 @@ class TestUtils(unittest.TestCase):
|
|||||||
"output": [("you-lora.safetensors", 0.2)],
|
"output": [("you-lora.safetensors", 0.2)],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"input": ("<lora:foo:1..2>, <lora:bar:.>, <lora:baz:+> and <lora:quux:>",[], 6),
|
"input": ("<lora:foo:1..2>, <lora:bar:.>, <lora:baz:+> and <lora:quux:>", [], 6),
|
||||||
"output": []
|
"output": []
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
for test in test_cases:
|
for test in test_cases:
|
||||||
promp, loras, loras_limit = test["input"]
|
prompt, loras, loras_limit = test["input"]
|
||||||
expected = test["output"]
|
expected = test["output"]
|
||||||
actual = util.parse_lora_references_from_prompt(promp, loras, loras_limit)
|
actual = util.parse_lora_references_from_prompt(prompt, loras, loras_limit)
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
|
|||||||
Reference in New Issue
Block a user