Skip to content

Commit

Permalink
adding test for warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
weinbe58 committed Sep 28, 2023
1 parent 5226e57 commit bb61cfe
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/test_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,33 @@ def test_batch_error(*args):
Chain(5, 6.1)
.rydberg.detuning.uniform.linear(-10, 10, 3.0)
.quera.mock()
.run(100)
.run_async(100)
)

error_files = glob.glob("partial-batch-errors-*")
batch_files = glob.glob("partial-batch-future-*")

assert len(error_files) == 1
assert len(batch_files) == 1

for error_file, batch_file in zip(error_files, batch_files):
os.remove(error_file)
os.remove(batch_file)


@patch("bloqade.ir.routine.quera.MockBackend")
def test_batch_warn(*args):
backend = bloqade.ir.routine.quera.MockBackend()

backend.submit_task.side_effect = ValueError("some random error")
backend.dict.return_value = {"state_file": ".mock_state.txt"}

with pytest.warns():
(
Chain(5, 6.1)
.rydberg.detuning.uniform.linear(-10, 10, 3.0)
.quera.mock()
.run_async(100, ignore_submission_error=True)
)

error_files = glob.glob("partial-batch-errors-*")
Expand Down

0 comments on commit bb61cfe

Please sign in to comment.