docs: add instructions for running unittests on embedded python, code cleanup

This commit is contained in:
Manuel Schmid 2024-05-18 16:55:39 +02:00
parent 4e610411fb
commit f4fc21d05d
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
2 changed files with 11 additions and 5 deletions

View File

@ -1,5 +1,11 @@
## Running unit tests
Native python:
```
python -m unittest tests/
```
Embedded python (Windows zip file installation method):
```
..\python_embeded\python.exe -m unittest
```

View File

@ -1,10 +1,10 @@
import unittest
from modules import util
class TestUtils(unittest.TestCase):
def test_can_parse_tokens_with_lora(self):
test_cases = [
{
"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)],
},
{
"input": ("<lora:foo:1..2>, <lora:bar:.>, <lora:baz:+> and <lora:quux:>",[], 6),
"output": []
"input": ("<lora:foo:1..2>, <lora:bar:.>, <lora:baz:+> and <lora:quux:>", [], 6),
"output": []
}
]
for test in test_cases:
promp, loras, loras_limit = test["input"]
prompt, loras, loras_limit = test["input"]
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)