Skip to content

Commit c4aa7bd

Browse files
committed
Fixed tests [skip ci]
1 parent 66bac99 commit c4aa7bd

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dev = [
3131
"SQLAlchemy[asyncio]>=2",
3232
"sqlmodel>=0.0.12"
3333
]
34-
dev2 = [
34+
dev-optional = [
3535
"numpy",
3636
"scipy"
3737
]

tests/test_bit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,21 @@
88

99

1010
class TestBit:
11+
@pytest.mark.skipif(np is None, reason='NumPy required')
1112
def test_list(self):
1213
assert Bit([True, False, True]).to_list() == [True, False, True]
1314

15+
@pytest.mark.skipif(np is None, reason='NumPy required')
1416
def test_list_none(self):
1517
with pytest.warns(UserWarning, match='expected elements to be boolean'):
1618
assert Bit([True, None, True]).to_text() == '101' # ty: ignore[invalid-argument-type]
1719

20+
@pytest.mark.skipif(np is None, reason='NumPy required')
1821
def test_list_int(self):
1922
with pytest.warns(UserWarning, match='expected elements to be boolean'):
2023
assert Bit([254, 7, 0]).to_text() == '110' # ty: ignore[invalid-argument-type]
2124

25+
@pytest.mark.skipif(np is None, reason='NumPy required')
2226
def test_str(self):
2327
assert Bit('101').to_list() == [True, False, True]
2428

@@ -49,20 +53,24 @@ def test_ndarray_uint16(self):
4953
with pytest.warns(UserWarning, match='expected elements to be boolean'):
5054
assert Bit(arr).to_text() == '110'
5155

56+
@pytest.mark.skipif(np is None, reason='NumPy required')
5257
def test_ndim_two(self):
5358
with pytest.raises(ValueError) as error:
5459
Bit([[True, False], [True, False]]) # ty: ignore[invalid-argument-type]
5560
assert str(error.value) == 'expected ndim to be 1'
5661

62+
@pytest.mark.skipif(np is None, reason='NumPy required')
5763
def test_ndim_zero(self):
5864
with pytest.raises(ValueError) as error:
5965
Bit(True) # ty: ignore[invalid-argument-type]
6066
assert str(error.value) == 'expected ndim to be 1'
6167

68+
@pytest.mark.skipif(np is None, reason='NumPy required')
6269
def test_repr(self):
6370
assert repr(Bit([True, False, True])) == 'Bit(101)'
6471
assert str(Bit([True, False, True])) == 'Bit(101)'
6572

73+
@pytest.mark.skipif(np is None, reason='NumPy required')
6674
def test_equality(self):
6775
assert Bit([True, False, True]) == Bit([True, False, True])
6876
assert Bit([True, False, True]) != Bit([True, False, False])

tests/test_psycopg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,21 @@ def test_halfvec_text_format(self):
9090
res = next(conn.execute('SELECT %t::halfvec', (embedding,)))[0]
9191
assert res == HalfVector([1.5, 2, 3])
9292

93+
@pytest.mark.skipif(np is None, reason='NumPy required')
9394
def test_bit(self):
9495
embedding = Bit([True, False, True])
9596
conn.execute('INSERT INTO psycopg_items (binary_embedding) VALUES (%s)', (embedding,))
9697

9798
res = next(conn.execute('SELECT binary_embedding FROM psycopg_items ORDER BY id'))[0]
9899
assert res == '101'
99100

101+
@pytest.mark.skipif(np is None, reason='NumPy required')
100102
def test_bit_binary_format(self):
101103
embedding = Bit([False, True, False, True, False, False, False, False, True])
102104
res = next(conn.execute('SELECT %b::bit(9)', (embedding,), binary=True))[0]
103105
assert repr(Bit.from_binary(res)) == 'Bit(010100001)'
104106

107+
@pytest.mark.skipif(np is None, reason='NumPy required')
105108
def test_bit_text_format(self):
106109
embedding = Bit([False, True, False, True, False, False, False, False, True])
107110
res = next(conn.execute('SELECT %t::bit(9)', (embedding,)))[0]

0 commit comments

Comments
 (0)