Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 7, 2026

pytest's filterwarnings = ["error"] configuration causes test collection to fail when spglib emits "Set OLD_ERROR_HANDLING to false" DeprecationWarning during module-level kVector initialization in test_kvec.py.

Changes

  • Wrap module-level kVector initialization with warnings.catch_warnings() context manager
  • Filter DeprecationWarning during initialization to prevent collection failure
  • Add import warnings to support the context manager

The existing @pytest.mark.filterwarnings("ignore::DeprecationWarning") decorators on test functions handle warnings during test execution but don't affect module-level code that runs during collection.

try:
    import seekpath
    # Suppress DeprecationWarning from spglib during module-level initialization
    # to prevent pytest from treating it as an error during test collection
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", category=DeprecationWarning)
        k_search = kvs.kVector(...)
except ModuleNotFoundError:
    k_search = None
Original prompt

Problem

The self-tests are failing during test collection with the following error from the workflow run https://github.com/AdvancedPhotonSource/GSAS-II-buildtools/actions/runs/20765654143:

ERROR tests/test_kvec.py - DeprecationWarning: Set OLD_ERROR_HANDLING to false and catch the errors directly.

This occurs at line 81 in tests/test_kvec.py when the kVector object is initialized at module level. The spglib library (used internally by seekpath) is issuing a deprecation warning about its error handling mechanism, and pytest is configured to treat warnings as errors during test collection.

Solution Required

Suppress the spglib DeprecationWarning during the module-level initialization of the k_search object in tests/test_kvec.py. The tests at lines 204 and 296 already have @pytest.mark.filterwarnings("ignore::DeprecationWarning") decorators, but this doesn't help with module-level code that runs during test collection.

The fix should wrap the module-level kVector initialization (lines 79-91) with warnings filtering to suppress the DeprecationWarning from spglib.

File to Modify

  • tests/test_kvec.py - Add warnings suppression around the module-level k_search initialization (lines 79-91)

Expected Behavior

After the fix, pytest should successfully collect all 22 tests without errors, and the test suite should run normally.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Suppress spglib deprecation warning during test collection Suppress spglib DeprecationWarning during module-level test initialization Jan 7, 2026
Copilot AI requested a review from briantoby January 7, 2026 02:26
@briantoby
Copy link
Collaborator

@Kvieta1990 The self-test after build of the self-installers is now failing (see here). My understanding is that seekpath calls spglib in a way that is deprecated which generates a warning and that warning crashes the self-test. We got this warning before but it did not crash the test. I suspect that we have now gone from spglib 2.6.0 to 2.7.0 and the severity of the warning has been stepped up and now the self-test fails.

I brought this up in September as a seekpath issue (giovannipizzi/seekpath#112) and heard that this has apparently was already resolved in their development branch, but they still have not put out an updated release. Are you OK with this change to suppress the warning for now?

@briantoby briantoby marked this pull request as ready for review January 7, 2026 18:39
@Kvieta1990
Copy link
Collaborator

Hi Brian, I am Ok with the suppression at this moment so please feel free to move forward. I will grab the new codes and test out manually on my side to make sure nothing is broken and things are still working properly. If things are changed, I will submit new issues which I will be working on to solve.

Does this sound like a plan? Thank you!

@briantoby briantoby merged commit ef4bc0b into main Jan 7, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants