Skip to content

Commit

Permalink
improve test failure msgs (#35)
Browse files Browse the repository at this point in the history
* improve test msg

* fix

* rollback

* improve comment

* update test
  • Loading branch information
aniketmaurya authored Apr 16, 2024
1 parent 2e44f61 commit 28aa1ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def batch(self, inputs):
return torch.stack(inputs)

def predict(self, x):
assert len(x) == 2
assert len(x) == 2, "Expected two concurrent inputs to be batched"
return self.model(x)

def unbatch(self, output):
Expand Down
11 changes: 5 additions & 6 deletions tests/test_lit_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import time
from multiprocessing import Pipe, Manager


import os

from unittest.mock import patch, MagicMock
Expand All @@ -30,14 +29,14 @@ def test_new_pipe(lit_server):
for _ in range(pool_size):
lit_server.new_pipe()

assert len(lit_server.pipe_pool) == 0
assert len(lit_server.new_pipe()) == 2
assert len(lit_server.pipe_pool) == 0, "All available pipes from the pipe_pool were used up, which makes it empty"
assert len(lit_server.new_pipe()) == 2, "lit_server.new_pipe() always must return a tuple of read and write pipes"


def test_dispose_pipe(lit_server):
for i in range(lit_server.max_pool_size + 10):
lit_server.dispose_pipe(*Pipe())
assert len(lit_server.pipe_pool) == lit_server.max_pool_size
assert len(lit_server.pipe_pool) == lit_server.max_pool_size, "pipe_pool size must be less than max_pool_size"


def test_index(sync_testclient):
Expand Down Expand Up @@ -114,8 +113,8 @@ def test_run():
)

time.sleep(5)
assert os.path.exists("client.py")
assert os.path.exists("client.py"), f"Expected client file to be created at {os.getcwd()} after starting the server"
output = subprocess.run("python client.py", shell=True, capture_output=True, text=True).stdout
assert '{"output":16.0}' in output
assert '{"output":16.0}' in output, "tests/simple_server.py didn't return expected output"
os.remove("client.py")
process.kill()

0 comments on commit 28aa1ae

Please sign in to comment.