Skip to content

Commit

Permalink
Make uberjob.Plan and various internal atom objects picklable
Browse files Browse the repository at this point in the history
  • Loading branch information
timothy-shields committed Jan 24, 2025
1 parent f77e3f1 commit a616445
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/uberjob/_util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def is_ipython():
class OmittedType:
def __new__(cls):
return Omitted

def __getnewargs__(self):
return ()

Expand All @@ -53,7 +53,7 @@ def __repr__(self):
class MissingType:
def __new__(cls):
return Missing

def __getnewargs__(self):
return ()

Expand Down
8 changes: 4 additions & 4 deletions tests/test_atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@

class AtomTestCase(unittest.TestCase):
def test_atom_singleton(self):
for atom_type, atom, atom_repr in ATOMS:
for atom_type, atom, _ in ATOMS:
with self.subTest(atom_type_name=atom_type.__name__):
self.assertIs(atom_type(), atom_type())
self.assertIs(atom_type(), atom)

def test_atom_pickle_round_trip_is_atom(self):
for atom_type, atom, atom_repr in ATOMS:
for atom_type, atom, _ in ATOMS:
with self.subTest(atom_type_name=atom_type.__name__):
self.assertIs(pickle.loads(pickle.dumps(atom)), atom)

def test_type_of_atom_is_atom_type(self):
for atom_type, atom, atom_repr in ATOMS:
for atom_type, atom, _ in ATOMS:
with self.subTest(atom_type_name=atom_type.__name__):
self.assertIs(type(atom), atom_type)

def test_atom_repr(self):
for atom_type, atom, atom_repr in ATOMS:
with self.subTest(atom_type_name=atom_type.__name__):
self.assertEqual(repr(atom), atom_repr)
self.assertEqual(repr(atom), atom_repr)
2 changes: 1 addition & 1 deletion tests/test_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,4 @@ def test_plan_pickle_round_trip(self):
result = plan.call(pow, 3, 2)
plan2, result2 = pickle.loads(pickle.dumps([plan, result]))
self.assertEqual(plan2._scope, ())
self.assertEqual(uberjob.run(plan2, output=result2), 9)
self.assertEqual(uberjob.run(plan2, output=result2), 9)

0 comments on commit a616445

Please sign in to comment.