Skip to content

Commit f58842c

Browse files
committed
Improved tests [skip ci]
1 parent d5dfd13 commit f58842c

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

tests/test_half_vector.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ class TestHalfVector:
88
def test_list(self):
99
assert HalfVector([1, 2, 3]).to_list() == [1, 2, 3]
1010

11+
def test_list_empty(self):
12+
assert HalfVector([]).to_list() == []
13+
1114
def test_list_str(self):
1215
with pytest.raises(ValueError) as error:
1316
HalfVector([1, 'two', 3]) # ty: ignore[invalid-argument-type]
1417
assert str(error.value) == 'expected list[float]'
1518

19+
def test_list_list(self):
20+
with pytest.raises(ValueError) as error:
21+
HalfVector([[1, 2], [3, 4]]) # ty: ignore[invalid-argument-type]
22+
assert str(error.value) == 'expected list[float]'
23+
1624
def test_ndarray(self):
1725
arr = np.array([1, 2, 3])
1826
assert HalfVector(arr).to_list() == [1, 2, 3]
1927
assert HalfVector(arr).to_numpy() is not arr
2028

21-
def test_ndim_two(self):
22-
with pytest.raises(ValueError) as error:
23-
HalfVector([[1, 2], [3, 4]]) # ty: ignore[invalid-argument-type]
24-
assert str(error.value) == 'expected list[float]'
25-
26-
def test_ndim_zero(self):
29+
def test_int(self):
2730
with pytest.raises(ValueError) as error:
2831
HalfVector(1) # ty: ignore[invalid-argument-type]
2932
assert str(error.value) == 'expected list or ndarray'

tests/test_vector.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,25 @@ class TestVector:
88
def test_list(self):
99
assert Vector([1, 2, 3]).to_list() == [1, 2, 3]
1010

11+
def test_list_empty(self):
12+
assert Vector([]).to_list() == []
13+
1114
def test_list_str(self):
1215
with pytest.raises(ValueError) as error:
1316
Vector([1, 'two', 3]) # ty: ignore[invalid-argument-type]
1417
assert str(error.value) == 'expected list[float]'
1518

19+
def test_list_list(self):
20+
with pytest.raises(ValueError) as error:
21+
Vector([[1, 2], [3, 4]]) # ty: ignore[invalid-argument-type]
22+
assert str(error.value) == 'expected list[float]'
23+
1624
def test_ndarray(self):
1725
arr = np.array([1, 2, 3])
1826
assert Vector(arr).to_list() == [1, 2, 3]
1927
assert Vector(arr).to_numpy() is not arr
2028

21-
def test_ndim_two(self):
22-
with pytest.raises(ValueError) as error:
23-
Vector([[1, 2], [3, 4]]) # ty: ignore[invalid-argument-type]
24-
assert str(error.value) == 'expected list[float]'
25-
26-
def test_ndim_zero(self):
29+
def test_int(self):
2730
with pytest.raises(ValueError) as error:
2831
Vector(1) # ty: ignore[invalid-argument-type]
2932
assert str(error.value) == 'expected list or ndarray'

0 commit comments

Comments
 (0)