Skip to content

Commit 9f8e635

Browse files
author
Joel Collins
committed
Unit test for core exceptions
1 parent ceb227f commit 9f8e635

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_core_exceptions.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from labthings.core import exceptions
2+
import pytest
3+
4+
5+
def test_lockerror_valid_code():
6+
from threading import Lock
7+
8+
lock = Lock()
9+
10+
assert exceptions.LockError("ACQUIRE_ERROR", lock)
11+
assert (
12+
str(exceptions.LockError("ACQUIRE_ERROR", lock))
13+
== f"ACQUIRE_ERROR: LOCK {lock}: Unable to acquire. Lock in use by another thread."
14+
)
15+
16+
17+
def test_lockerror_invalid_code():
18+
from threading import Lock
19+
20+
lock = Lock()
21+
22+
assert exceptions.LockError("INVALID_ERROR", lock)
23+
assert (
24+
str(exceptions.LockError("INVALID_ERROR", lock))
25+
== f"INVALID_ERROR: LOCK {lock}: Unknown error."
26+
)

0 commit comments

Comments
 (0)