Skip to content

Commit

Permalink
skip tests with extra requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjj committed Feb 5, 2025
1 parent 02f4531 commit 1ae02bc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/colocated_python_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import threading
import time
from typing import Sequence
import unittest

from absl.testing import absltest
from absl.testing import parameterized
Expand All @@ -30,6 +31,10 @@
config.parse_flags_with_absl()
jtu.request_cpu_devices(8)

try:
import cloudpickle # noqa
except (ModuleNotFoundError, ImportError):
raise unittest.SkipTest("tests depend on cloudpickle library")

def _colocated_cpu_devices(
devices: Sequence[jax.Device],
Expand Down
3 changes: 3 additions & 0 deletions tests/export_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def f(a_b_pair, a, b):
exp_f.call((a, b), a=a, b=b))

def test_pytree_namedtuple(self):
if not CAN_SERIALIZE: raise unittest.SkipTest("test requires flatbuffers")
T = collections.namedtuple("SomeType", ("a", "b", "c"))
export.register_namedtuple_serialization(
T,
Expand All @@ -317,6 +318,7 @@ def f(x):
tree_util.tree_structure(res))

def test_pytree_namedtuple_error(self):
if not CAN_SERIALIZE: raise unittest.SkipTest("test requires flatbuffers")
T = collections.namedtuple("SomeType", ("a", "b"))
x = T(a=1, b=2)
with self.assertRaisesRegex(
Expand Down Expand Up @@ -363,6 +365,7 @@ def test_pytree_namedtuple_error(self):
)

def test_pytree_custom_types(self):
if not CAN_SERIALIZE: raise unittest.SkipTest("test requires flatbuffers")
x1 = collections.OrderedDict([("foo", 34), ("baz", 101), ("something", -42)])

@tree_util.register_pytree_node_class
Expand Down

0 comments on commit 1ae02bc

Please sign in to comment.