Skip to content

Commit 007f4f7

Browse files
committed
Tests cleaned up
1 parent 98947d1 commit 007f4f7

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

launch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,17 @@ def prepare_enviroment():
229229
def tests(argv):
230230
if "--api" not in argv:
231231
argv.append("--api")
232+
if "--ckpt" not in argv:
233+
argv.append("--ckpt")
234+
argv.append("./test/test_files/empty.pt")
232235

233236
print(f"Launching Web UI in another process for testing with arguments: {' '.join(argv[1:])}")
234237

235238
with open('test/stdout.txt', "w", encoding="utf8") as stdout, open('test/stderr.txt', "w", encoding="utf8") as stderr:
236239
proc = subprocess.Popen([sys.executable, *argv], stdout=stdout, stderr=stderr)
237240

238241
import test.server_poll
239-
test.server_poll.run_tests()
242+
test.server_poll.run_tests(proc)
240243

241244
print(f"Stopping Web UI process with id {proc.pid}")
242245
proc.kill()

test/server_poll.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
import time
44

55

6-
def run_tests():
6+
def run_tests(proc):
77
timeout_threshold = 240
88
start_time = time.time()
99
while time.time()-start_time < timeout_threshold:
1010
try:
1111
requests.head("http://localhost:7860/")
1212
break
1313
except requests.exceptions.ConnectionError:
14-
pass
15-
if time.time()-start_time < timeout_threshold:
14+
if proc.poll() is not None:
15+
break
16+
if proc.poll() is None:
1617
suite = unittest.TestLoader().discover('', pattern='*_test.py')
1718
result = unittest.TextTestRunner(verbosity=2).run(suite)
1819
else:

test/test_files/empty.pt

431 Bytes
Binary file not shown.

test/txt2img_test.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ def test_txt2img_with_restore_faces_performed(self):
5353
self.simple_txt2img["restore_faces"] = True
5454
self.assertEqual(requests.post(self.url_txt2img, json=self.simple_txt2img).status_code, 200)
5555

56-
def test_txt2img_with_tiling_faces_performed(self):
56+
def test_txt2img_with_tiling_performed(self):
5757
self.simple_txt2img["tiling"] = True
5858
self.assertEqual(requests.post(self.url_txt2img, json=self.simple_txt2img).status_code, 200)
5959

6060
def test_txt2img_with_vanilla_sampler_performed(self):
6161
self.simple_txt2img["sampler_index"] = "PLMS"
6262
self.assertEqual(requests.post(self.url_txt2img, json=self.simple_txt2img).status_code, 200)
63+
self.simple_txt2img["sampler_index"] = "DDIM"
64+
self.assertEqual(requests.post(self.url_txt2img, json=self.simple_txt2img).status_code, 200)
6365

6466
def test_txt2img_multiple_batches_performed(self):
6567
self.simple_txt2img["n_iter"] = 2

test/utils_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ def setUp(self):
1818
def test_options_get(self):
1919
self.assertEqual(requests.get(self.url_options).status_code, 200)
2020

21-
def test_options_write(self):
22-
response = requests.get(self.url_options)
23-
self.assertEqual(response.status_code, 200)
21+
# def test_options_write(self):
22+
# response = requests.get(self.url_options)
23+
# self.assertEqual(response.status_code, 200)
2424

25-
pre_value = response.json()["send_seed"]
25+
# pre_value = response.json()["send_seed"]
2626

27-
self.assertEqual(requests.post(self.url_options, json={"send_seed":not pre_value}).status_code, 200)
27+
# self.assertEqual(requests.post(self.url_options, json={"send_seed":not pre_value}).status_code, 200)
2828

29-
response = requests.get(self.url_options)
30-
self.assertEqual(response.status_code, 200)
31-
self.assertEqual(response.json()["send_seed"], not pre_value)
29+
# response = requests.get(self.url_options)
30+
# self.assertEqual(response.status_code, 200)
31+
# self.assertEqual(response.json()["send_seed"], not pre_value)
3232

33-
requests.post(self.url_options, json={"send_seed": pre_value})
33+
# requests.post(self.url_options, json={"send_seed": pre_value})
3434

3535
def test_cmd_flags(self):
3636
self.assertEqual(requests.get(self.url_cmd_flags).status_code, 200)

0 commit comments

Comments
 (0)