Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: remove package-availability skips
pyobjcryst and diffpy.structure are declared test and runtime
dependencies, so the tests should fail rather than silently skip when
they are missing. Remove the pyobjcryst_available and
diffpy_structure_available fixtures, their skip checks, and the cctbx
import guard in the already-disabled xtestCreateSpaceGroup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
cadenmyers13 and claude committed Oct 7, 2026
commit 7b730f88b2c0dd7773db043ad754c7e4b8d978ce
42 changes: 0 additions & 42 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import importlib.resources
import json
import logging
from functools import lru_cache
from pathlib import Path

import pytest

logger = logging.getLogger(__name__)


@pytest.fixture
def user_filesystem(tmp_path):
Expand All @@ -24,44 +20,6 @@ def user_filesystem(tmp_path):
yield tmp_path


# diffpy.structure
@lru_cache()
def has_diffpy_structure():
try:
import diffpy.structure as m

del m
return True
except ImportError:
logger.warning(
"Cannot import diffpy.structure, Structure tests skipped."
)
return False


# pyobjcryst
@lru_cache()
def has_pyobjcryst():
try:
import pyobjcryst as m

del m
return True
except ImportError:
logger.warning("Cannot import pyobjcryst, pyobjcryst tests skipped.")
return False


@pytest.fixture(scope="session")
def diffpy_structure_available():
return has_diffpy_structure()


@pytest.fixture(scope="session")
def pyobjcryst_available():
return has_pyobjcryst()


@pytest.fixture(scope="session")
def datafile():
"""Fixture to load a test data file from the testdata package
Expand Down
17 changes: 3 additions & 14 deletions tests/test_objcrystparset.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,8 @@ def makeC60():

class TestParameterAdapter:
@pytest.fixture(autouse=True)
def setup(self, pyobjcryst_available):
def setup(self):
# shared setup
if not pyobjcryst_available:
pytest.skip("pyobjcryst package not available")

global ObjCrystCrystalParSet, Crystal, Atom, Molecule
global ScatteringPowerAtom
from pyobjcryst.atom import Atom
Expand Down Expand Up @@ -626,13 +623,8 @@ class TestCreateSpaceGroup:
"""

@pytest.fixture(autouse=True)
def setup(self, diffpy_structure_available, pyobjcryst_available):
def setup(self):
# shared setup
if not diffpy_structure_available:
pytest.skip("diffpy.structure package not available")
if not pyobjcryst_available:
pytest.skip("pyobjcryst package not available")

global ObjCrystCrystalParSet, spacegroups
from diffpy.cmistructure.objcrystparset import ObjCrystCrystalParSet
from diffpy.structure import spacegroups
Expand Down Expand Up @@ -665,10 +657,7 @@ def sgsEquivalent(self, sg1, sg2):
def xtestCreateSpaceGroup(self):
"""Check all sgtbx space groups for proper conversion to
SpaceGroup."""
try:
from cctbx import sgtbx
except ImportError:
return
from cctbx import sgtbx

for smbls in sgtbx.space_group_symbol_iterator():
shn = smbls.hermann_mauguin()
Expand Down
15 changes: 3 additions & 12 deletions tests/test_sgconstraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@
# ----------------------------------------------------------------------------


def test_ObjCryst_constrain_space_group(pyobjcryst_available):
def test_ObjCryst_constrain_space_group():
"""Make sure that all Parameters are constrained properly.

This tests constrainSpaceGroup from
diffpy.cmistructure.sgconstraints, which is performed automatically
when an ObjCrystCrystalParSet is created.
"""
if not pyobjcryst_available:
pytest.skip("pyobjcrysta package not available")

from diffpy.cmistructure.objcrystparset import ObjCrystCrystalParSet

pi = numpy.pi
Expand Down Expand Up @@ -105,11 +102,8 @@ def test_ObjCryst_constrain_space_group(pyobjcryst_available):
return


def test_DiffPy_constrain_as_space_group(datafile, pyobjcryst_available):
def test_DiffPy_constrain_as_space_group(datafile):
"""Test the constrain_as_space_group function."""
if not pyobjcryst_available:
pytest.skip("pyobjcrysta package not available")

from diffpy.cmistructure.diffpyparset import DiffpyStructureParSet
from diffpy.cmistructure.sgconstraints import constrain_as_space_group

Expand Down Expand Up @@ -182,12 +176,9 @@ def _alltests(parameter):
return


def test_constrain_as_space_group_args(pyobjcryst_available, datafile):
def test_constrain_as_space_group_args(datafile):
"""Test the arguments processing of constrain_as_space_group
function."""
if not pyobjcryst_available:
pytest.skip("pyobjcrysta package not available")

from diffpy.cmistructure.diffpyparset import DiffpyStructureParSet
from diffpy.cmistructure.sgconstraints import constrain_as_space_group
from diffpy.structure.spacegroups import GetSpaceGroup
Expand Down