Skip to content

Commit

Permalink
feat: add tests to check tasks can be pickled
Browse files Browse the repository at this point in the history
  • Loading branch information
hiro-o918 committed Oct 13, 2024
1 parent 8bd8fe0 commit a8d23f7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/test_task_on_kart.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import pathlib
import pickle
import unittest
from datetime import datetime
from typing import Any, Dict, List, cast
Expand Down Expand Up @@ -657,5 +658,18 @@ def test_run_when_complete_check_at_run_is_true_and_task_is_completed(self):
task.dump.assert_not_called()


class TestPickleTaskOnKart:
def test_pickle_and_unpickle(self):
task = _DummyTask(redis_host='0.0.0.0', redis_port=12345, redis_timeout=180, should_lock_run=True)
pickled = pickle.dumps(task)
unpickled = pickle.loads(pickled)
assert task.to_str_params() == unpickled.to_str_params()

task = _DummyTask(should_lock_run=False)
pickled = pickle.dumps(task)
unpickled = pickle.loads(pickled)
assert task.to_str_params() == unpickled.to_str_params()


if __name__ == '__main__':
unittest.main()

0 comments on commit a8d23f7

Please sign in to comment.