Skip to content

test: remove pytest.skip when a package is not installed #152

Closed

Description

@cadenmyers13

Problem

Some of these older tests skip pytest if a package is not imported into the developer's environment. This looks something like the following,

def test_pickling(diffpy_structure_available):
    """Test pickling of DiffpyStructureParSet."""
    if not diffpy_structure_available:
        pytest.skip("diffpy.structure package not available")
    from diffpy.structure import Atom, Structure

    stru = Structure([Atom("C", [0, 0.2, 0.5])])
    dsps = DiffpyStructureParSet("dsps", stru)
    data = pickle.dumps(dsps)
    dsps2 = pickle.loads(data)
    assert 1 == len(dsps2.atoms)
    assert 0.2 == dsps2.atoms[0].y.value
    return

This is not the best behavior. If the developer doesnt have this package installed into their environment, this test should fail and they should install the necessary package.

Proposed solution

Remove the if not <package_name>: conditional and its associated fixture(s) in conftest.py. The test should then look something like this,

def test_pickling():
    """Test pickling of DiffpyStructureParSet."""
    from diffpy.structure import Atom, Structure

    stru = Structure([Atom("C", [0, 0.2, 0.5])])
    dsps = DiffpyStructureParSet("dsps", stru)
    data = pickle.dumps(dsps)
    dsps2 = pickle.loads(data)
    assert 1 == len(dsps2.atoms)
    assert 0.2 == dsps2.atoms[0].y.value
    return

Activity

  1. cadenmyers13 commented on Feb 9, 2026

    @cadenmyers13
    ContributorAuthor

    @sbillinge Do you know/remember if this pytest.skip was implemented for any reason? if not, we can proceed with this.

  2. sbillinge commented on Feb 10, 2026

    @sbillinge
    Contributor

    I think we can remove that, especially since diffpy.structure is part of the core. But I guess there is a question in general about how we test packs. If we test all the packs we will run into problems if a pack is not maintained, but if we don't test packs then we aren't testing all our functionality. Do you have thoughts on this?

  3. added this to the 3.3.0-rc.0 milestone on Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions