Skip to content

Commit 0835e33

Browse files
Jammy2211claude
authored andcommitted
test(conftest): remove jax from conftest entirely (numpy-only rule)
Per the 'library unit tests stay numpy-only' rule, conftest must not import jax at all — not even via try/except. Replace the eager import + jax.config.update + jnp.sum-warmup with a find_spec-gated collect_ignore_glob that skips test_jax_*.py files when jax isn't installed. find_spec checks availability without importing. This supersedes the prior try/except approach in 07fcc0e. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 07fcc0e commit 0835e33

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

test_autoarray/conftest.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
try:
2-
import jax
3-
import jax.numpy as jnp
4-
5-
jax.config.update("jax_enable_x64", True)
6-
_JAX_AVAILABLE = True
7-
except ImportError:
8-
_JAX_AVAILABLE = False
9-
10-
11-
def pytest_configure():
12-
if _JAX_AVAILABLE:
13-
_ = jnp.sum(jnp.array([0.0])) # Force backend init
14-
15-
1+
import importlib.util
162
import os
173
from os import path
184
import pytest
@@ -21,6 +7,13 @@ def pytest_configure():
217
from autoarray import fixtures
228
from autoconf import conf
239

10+
# Skip JAX-only tests when jax isn't installed. find_spec checks availability
11+
# WITHOUT importing the module, so this conftest stays numpy-only per the
12+
# "library unit tests stay numpy-only" rule.
13+
collect_ignore_glob = []
14+
if importlib.util.find_spec("jax") is None:
15+
collect_ignore_glob = ["test_jax_*.py", "**/test_jax_*.py"]
16+
2417

2518
class PlotPatch:
2619
def __init__(self):

0 commit comments

Comments
 (0)