Skip to content

Commit

Permalink
added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-shields committed Feb 9, 2024
1 parent 716718c commit 5df87bd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
import operator
import os
import pathlib
import pickle
import re
import tempfile

import networkx as nx

import uberjob
from uberjob._errors import NodeError
from uberjob._util.traceback import get_stack_frame
from uberjob.graph import Call
from uberjob.progress import console_progress, default_progress, html_progress
Expand Down Expand Up @@ -373,3 +375,33 @@ def wrapper(*args, **kwargs):
expected_exception_chain_traceback_summary=[["wrapper"]]
):
uberjob.run(plan, output=call, retry=bad_retry2)

def test_serialize_call_error(self):
plan = uberjob.Plan()
call = plan.call(operator.truediv, 1, 0)
exception = None
try:
uberjob.run(plan, output=call)
except uberjob.CallError as e:
exception = e
self.assertIsNotNone(exception)
pickled_exception = pickle.dumps(exception)
unpickled_exception = pickle.loads(pickled_exception)
self.assertIsInstance(unpickled_exception, uberjob.CallError)
self.assertIsInstance(unpickled_exception.call, Call)
self.assertIs(unpickled_exception.call.fn, operator.truediv)

def test_serialize_node_error(self):
plan = uberjob.Plan()
call = plan.call(pow, 2, 2)
exception = None
try:
raise NodeError(call)
except NodeError as e:
exception = e
self.assertIsNotNone(exception)
pickled_exception = pickle.dumps(exception)
unpickled_exception = pickle.loads(pickled_exception)
self.assertIsInstance(unpickled_exception, NodeError)
self.assertIsInstance(unpickled_exception.node, Call)
self.assertIs(unpickled_exception.node.fn, pow)

0 comments on commit 5df87bd

Please sign in to comment.