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
2 changed files with 11 additions and 5 deletions
+6
View File
@@ -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
```
+3 -3
View File
@@ -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),
@@ -42,7 +42,7 @@ class TestUtils(unittest.TestCase):
] ]
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)