Skip to content

Commit d5f14bd

Browse files
test: Add tests for __getitem__ only
1 parent f677b53 commit d5f14bd

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

tests/test_dataframe_compatibility.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,87 @@ def test_LO_len() -> None:
134134
_get_value=lambda *_: _,
135135
)
136136
assert process._length == 10
137+
138+
139+
# >>>>>>>>>> Get Only <<<<<<<<<< #
140+
def test_GO_init_int() -> None:
141+
ParallelProcessing(function=lambda x: x, dataset=DummyGetOnly([1, 2, 3]), _length=3)
142+
143+
144+
def test_GO_init_func() -> None:
145+
ParallelProcessing(
146+
function=lambda x: x, dataset=DummyGetOnly([1, 2, 3]), _length=lambda _: 3
147+
)
148+
149+
150+
def test_GO_init_missingLengthError() -> None:
151+
with pytest.raises(TypeError):
152+
ParallelProcessing(
153+
function=lambda x: x,
154+
dataset=DummyGetOnly([1, 2, 3]), # type: ignore
155+
)
156+
157+
158+
def test_GO_init_nonIntLengthError_strLike() -> None:
159+
with pytest.raises(TypeError):
160+
ParallelProcessing(
161+
function=lambda x: x,
162+
dataset=DummyGetOnly([1, 2, 3]),
163+
_length='10', # type: ignore
164+
)
165+
166+
167+
def test_GO_init_nonIntLengthError_numLike() -> None:
168+
with pytest.raises(TypeError):
169+
ParallelProcessing(
170+
function=lambda x: x,
171+
dataset=DummyGetOnly([1, 2, 3]),
172+
_length=10.5, # type: ignore
173+
)
174+
175+
176+
def test_GO_init_nonIntLengthError_negative() -> None:
177+
with pytest.raises(ValueError):
178+
ParallelProcessing(
179+
function=lambda x: x,
180+
dataset=DummyGetOnly([1, 2, 3]),
181+
_length=-10, # type: ignore
182+
)
183+
184+
185+
def test_GO_enforceTypes() -> None:
186+
def validate(x, i):
187+
assert isinstance(x, DummyGetOnly)
188+
assert isinstance(i, int)
189+
190+
process = ParallelProcessing(
191+
function=lambda x: x,
192+
dataset=DummyGetOnly([1, 2, 3]),
193+
_length=3,
194+
_get_value=validate,
195+
)
196+
process.start()
197+
process.join()
198+
199+
200+
def test_GO_len() -> None:
201+
process = ParallelProcessing(
202+
function=lambda x: x,
203+
dataset=DummyGetOnly([1, 2, 3]),
204+
_length=3,
205+
_get_value=lambda *_: _,
206+
)
207+
assert process._length == 3
208+
209+
210+
def test_GO_get() -> None:
211+
def get(*_):
212+
return _
213+
214+
process = ParallelProcessing(
215+
function=lambda x: x,
216+
dataset=DummyGetOnly([1, 2, 3]),
217+
_length=3,
218+
_get_value=get,
219+
)
220+
assert process._retrieve_value == get

0 commit comments

Comments
 (0)