Bug 2273562 - python-ase fails to build with pytest 8: TypeError: exceptions must be derived from Warning, not <class 'NoneType'>
Summary: python-ase fails to build with pytest 8: TypeError: exceptions must be derive...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-ase
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: marcindulak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2256331
TreeView+ depends on / blocked
 
Reported: 2024-04-05 07:43 UTC by Tomáš Hrnčiar
Modified: 2024-04-06 22:17 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2024-04-06 22:17:09 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2024-04-05 07:43:56 UTC
python-ase fails to build with pytest 8.



=================================== FAILURES ===================================
___________________________ test_fundamental_params ____________________________

    def test_fundamental_params():
        # Start by testing the fundamental parts of a CastepCell/CastepParam object
        boolOpt = CastepOption('test_bool', 'basic', 'defined')
        boolOpt.value = 'TRUE'
        assert boolOpt.raw_value is True
    
        float3Opt = CastepOption('test_float3', 'basic', 'real vector')
        float3Opt.value = '1.0 2.0 3.0'
        assert np.isclose(float3Opt.raw_value, [1, 2, 3]).all()
    
        # Generate a mock keywords object
        mock_castep_keywords = CastepKeywords(make_param_dict(), make_cell_dict(),
                                              [], [], 0)
        mock_cparam = CastepParam(mock_castep_keywords, keyword_tolerance=2)
        mock_ccell = CastepCell(mock_castep_keywords, keyword_tolerance=2)
    
        # Test special parsers
        mock_cparam.continuation = 'default'
>       with pytest.warns(None):

/builddir/build/BUILD/ase-3.22.1/ase/test/calculator/castep/test_castep_interface.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = WarningsChecker(record=True), expected_warning = None, match_expr = None

    def __init__(
        self,
        expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = Warning,
        match_expr: Optional[Union[str, Pattern[str]]] = None,
        *,
        _ispytest: bool = False,
    ) -> None:
        check_ispytest(_ispytest)
        super().__init__(_ispytest=True)
    
        msg = "exceptions must be derived from Warning, not %s"
        if isinstance(expected_warning, tuple):
            for exc in expected_warning:
                if not issubclass(exc, Warning):
                    raise TypeError(msg % type(exc))
            expected_warning_tup = expected_warning
        elif isinstance(expected_warning, type) and issubclass(
            expected_warning, Warning
        ):
            expected_warning_tup = (expected_warning,)
        else:
>           raise TypeError(msg % type(expected_warning))
E           TypeError: exceptions must be derived from Warning, not <class 'NoneType'>

/usr/lib/python3.12/site-packages/_pytest/recwarn.py:285: TypeError
_________________________________ test_imports _________________________________

    @pytest.mark.filterwarnings('ignore:Moved to')
    def test_imports():
        for module in all_modules:
            if module in deprecated_modules:
                warning = (DeprecationWarning, VisibleDeprecationWarning)
            else:
                warning = None
    
            try:
>               with pytest.warns(warning):

/builddir/build/BUILD/ase-3.22.1/ase/test/test_imports.py:67: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = WarningsChecker(record=True), expected_warning = None, match_expr = None

    def __init__(
        self,
        expected_warning: Union[Type[Warning], Tuple[Type[Warning], ...]] = Warning,
        match_expr: Optional[Union[str, Pattern[str]]] = None,
        *,
        _ispytest: bool = False,
    ) -> None:
        check_ispytest(_ispytest)
        super().__init__(_ispytest=True)
    
        msg = "exceptions must be derived from Warning, not %s"
        if isinstance(expected_warning, tuple):
            for exc in expected_warning:
                if not issubclass(exc, Warning):
                    raise TypeError(msg % type(exc))
            expected_warning_tup = expected_warning
        elif isinstance(expected_warning, type) and issubclass(
            expected_warning, Warning
        ):
            expected_warning_tup = (expected_warning,)
        else:
>           raise TypeError(msg % type(expected_warning))
E           TypeError: exceptions must be derived from Warning, not <class 'NoneType'>

/usr/lib/python3.12/site-packages/_pytest/recwarn.py:285: TypeError
________________ TestHarmonicVibrations.test_vibrations_methods ________________

self = <ase.test.vibrations.test_vib.TestHarmonicVibrations object at 0x7f67511fb020>
testdir = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_vibrations_methods0')
random_dimer = Atoms(symbols='CuP', pbc=False, calculator=ForceConstantCalculator(...))

    def test_vibrations_methods(self, testdir, random_dimer):
        vib = Vibrations(random_dimer)
        vib.run()
        vib_energies = vib.get_energies()
    
        for image in vib.iterimages():
            assert len(image) == 2
    
        thermo = IdealGasThermo(vib_energies=vib_energies, geometry='linear',
                                atoms=vib.atoms, symmetrynumber=2, spin=0)
        thermo.get_gibbs_energy(temperature=298.15, pressure=2 * 101325.,
                                verbose=False)
    
>       with open(self.logfile, 'w') as fd:
E       AttributeError: 'TestHarmonicVibrations' object has no attribute 'logfile'

/builddir/build/BUILD/ase-3.22.1/ase/test/vibrations/test_vib.py:135: AttributeError
____________________ TestVibrationsData.test_jmol_roundtrip ____________________

self = <ase.test.vibrations.test_vib.TestVibrationsData object at 0x7f6751251220>
testdir = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_jmol_roundtrip0')
n2_data = {'atoms': Atoms(symbols='N2', pbc=False), 'hessian': array([[[[ 4.67554672e-03,  0.00000000e+00,  0.00000000e+00],
   ...ef_frequencies': [0j, (6.0677553e-08+0j), (3.62010442e-06+0j), (13.4737571+0j), (13.4737571+0j), (1231.18496+0j)], ...}

    def test_jmol_roundtrip(self, testdir, n2_data):
        ir_intensities = np.random.RandomState(42).rand(6)
    
        vib_data = VibrationsData(n2_data['atoms'], n2_data['hessian'])
>       vib_data.write_jmol(self.jmol_file, ir_intensities=ir_intensities)
E       AttributeError: 'TestVibrationsData' object has no attribute 'jmol_file'

/builddir/build/BUILD/ase-3.22.1/ase/test/vibrations/test_vib.py:454: AttributeError
=============================== warnings summary ===============================
../atoms.py:1205: 1 warning
atoms/test_atom_scaled_pos.py: 3 warnings
atoms/test_get_angles.py: 1 warning
build_/test_bulk.py: 1 warning
build_/test_surface.py: 1 warning
calculator/socketio/test_python_interface.py: 1 warning
calculator/vasp/test_vasp_input.py: 14 warnings
constraints/test_repeat_FixAtoms.py: 1 warning
fio/test_cif.py: 1 warning
fio/test_extxyz.py: 3 warnings
fio/test_pickle_bundle_trajectory.py: 6 warnings
fio/test_trajectory_heterogeneous.py: 1 warning
forcefields/test_forceqmmm.py: 13 warnings
ga/test_basic_example_main_run.py: 1 warning
ga/test_bulk_operators.py: 1 warning
ga/test_chain_operators.py: 1 warning
ga/test_cutandsplicepairing.py: 1 warning
ga/test_database_logic.py: 1 warning
ga/test_film_operators.py: 1 warning
ga/test_mutations.py: 1 warning
md/test_ce_logging.py: 1 warning
md/test_ce_potentiostat.py: 1 warning
md/test_idealgas.py: 1 warning
md/test_langevin_switching.py: 1 warning
neb/test_COCu111.py: 1 warning
neb/test_COCu111_2.py: 1 warning
neighbor/test_neighbor.py: 2 warnings
neighbor/test_neighbor_kernel.py: 1 warning
optimize/test_optimizers.py: 15 warnings
precon/test_amin.py: 1 warning
precon/test_lbfgs.py: 1 warning
precon/test_precon_assembly.py: 36 warnings
precon/test_unitcellfilter.py: 1 warning
spacegroup/test_spacegroup_utils.py: 13 warnings
test_dimensionality.py: 3 warnings
test_doctests.py: 2 warnings
test_external_viewer.py: 1 warning
test_geometry.py: 1 warning
test_springcalc.py: 1 warning
test_structure_comparator.py: 19 warnings
test_things.py: 1 warning
vibrations/test_bond_polarizability_raman.py: 2 warnings
  /builddir/build/BUILD/ase-3.22.1/ase/atoms.py:1205: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= rep

build_/test_surface.py::test_surface
build_/test_surface_terminations.py::test_surface_terminations
  /builddir/build/BUILD/ase-3.22.1/ase/build/general_surface.py:77: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    surf *= (1, 1, layers)

build_/test_surface_terminations.py::test_surface_terminations
  /builddir/build/BUILD/ase-3.22.1/ase/test/build_/test_surface_terminations.py:14: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    slb *= (1, 2, 1)

calculator/socketio/test_ipi_protocol_bfgs.py::test_ipi_protocol[inet]
calculator/socketio/test_ipi_protocol_bfgs.py::test_ipi_protocol[unix]
  /builddir/build/BUILD/ase-3.22.1/ase/calculators/socketio.py:106: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    natoms = int(natoms)

calculator/socketio/test_python_interface.py::test_socketio_python
  /builddir/build/BUILD/ase-3.22.1/ase/calculators/socketio.py:118: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    forces = self.recv((int(natoms), 3), np.float64)

constraints/test_parameteric_constr.py::test_parameteric_constr
fio/test_aims_io.py::test_parse_geometry_lines
test_parsemath.py::test_parsemath
  /builddir/build/BUILD/ase-3.22.1/ase/utils/parsemath.py:146: DeprecationWarning: ast.Num is deprecated and will be removed in Python 3.14; use ast.Constant instead
    if isinstance(node, ast.Num):  # <number>

constraints/test_parameteric_constr.py::test_parameteric_constr
fio/test_aims_io.py::test_parse_geometry_lines
test_parsemath.py::test_parsemath
  /builddir/build/BUILD/ase-3.22.1/ase/utils/parsemath.py:147: DeprecationWarning: Attribute n is deprecated and will be removed in Python 3.14; use value instead
    return node.n

emt/test_emt_stress.py::test_emt_stress
  /builddir/build/BUILD/ase-3.22.1/ase/test/emt/test_emt_stress.py:13: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    a *= (1, 2, 3)

fio/test_oi.py: 77 warnings
  /builddir/build/BUILD/ase-3.22.1/ase/test/fio/test_oi.py:33: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= (2, 1, 1)

fio/test_v_sim.py::test_v_sim
  /builddir/build/BUILD/ase-3.22.1/ase/utils/__init__.py:486: DeprecationWarning: `alltrue` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `all` instead.
    obj = func(fd, *args, **kwargs)

md/test_md.py::test_md
  /builddir/build/BUILD/ase-3.22.1/ase/test/md/test_md.py:13: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    fcc *= (2, 1, 1)

neb/test_precon_neb.py::test_neb_methods[aseneb-BFGS-None-None]
  /builddir/build/BUILD/ase-3.22.1/ase/test/neb/test_precon_neb.py:26: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    initial *= N_cell

neighbor/test_neighbor.py::test_small_cell_and_large_cutoff
  /builddir/build/BUILD/ase-3.22.1/ase/test/neighbor/test_neighbor.py:193: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= (2, 2, 2)

optimize/test_fire.py::test_fire
  /builddir/build/BUILD/ase-3.22.1/ase/test/optimize/test_fire.py:12: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    a *= (2, 2, 2)

optimize/test_replay.py::test_replay
  /builddir/build/BUILD/ase-3.22.1/ase/test/optimize/test_replay.py:17: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    a *= (2, 2, 1)  # 2x2 (100) surface-cell

precon/test_lbfgs.py::test_preconlbfgs
  /builddir/build/BUILD/ase-3.22.1/ase/test/precon/test_lbfgs.py:15: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    a0 *= (N, N, N)

test_basin.py::test_basin
  /builddir/build/BUILD/ase-3.22.1/ase/optimize/basin.py:71: DeprecationWarning: `sometrue` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `any` instead.
    self.Emin = self.get_energy(self.atoms.get_positions()) or 1.e32

test_dimensionality.py::test_mx2[TSA]
test_dimensionality.py::test_mx2[RDA]
  /builddir/build/BUILD/ase-3.22.1/ase/test/test_dimensionality.py:14: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= 2

test_dimensionality.py::test_isolation_2D
  /builddir/build/BUILD/ase-3.22.1/ase/test/test_dimensionality.py:80: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= 2

test_geometry_derivatives.py::test_atoms_angle
  /builddir/build/BUILD/ase-3.22.1/ase/test/test_geometry_derivatives.py:42: DeprecationWarning: Conversion of an array with ndim > 0 to a scalar is deprecated, and will error in future. Ensure you extract a single element from your array before performing this operation. (Deprecated NumPy 1.25.)
    derivs[i, j] = (plus - minus) / (2 * epsilon)

test_potential_energies.py::test_potential_energies
  /builddir/build/BUILD/ase-3.22.1/ase/test/test_potential_energies.py:10: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= (2, 2, 2)

test_root_surf.py::test_root_surf
  /builddir/build/BUILD/ase-3.22.1/ase/build/root.py:172: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= (root, root, 1)

test_stress.py::test_stress
  /builddir/build/BUILD/ase-3.22.1/ase/test/test_stress.py:45: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    atoms *= (1, 2, 3)

test_structure_comparator.py::test_supercell_w_periodic_atom_removed
  /builddir/build/BUILD/ase-3.22.1/ase/test/test_structure_comparator.py:294: DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be removed in NumPy 2.0. Please use `prod` instead.
    s1 *= (2, 1, 1)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED calculator/castep/test_castep_interface.py::test_fundamental_params - ...
FAILED test_imports.py::test_imports - TypeError: exceptions must be derived ...
FAILED vibrations/test_vib.py::TestHarmonicVibrations::test_vibrations_methods
FAILED vibrations/test_vib.py::TestVibrationsData::test_jmol_roundtrip - Attr...
= 4 failed, 1691 passed, 379 skipped, 2 xfailed, 266 warnings in 153.01s (0:02:33) =

https://docs.pytest.org/en/stable/changelog.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/thrnciar/pytest/fedora-rawhide-x86_64/07247731-python-ase/

For all our attempts to build python-ase with pytest 8, see:
https://copr.fedorainfracloud.org/coprs/thrnciar/pytest/package/python-ase/

Let us know here if you have any questions.

Pytest 8 is planned to be included in Fedora 41. And this bugzilla is a
heads up before we merge new pytest into rawhide. For more info see a Fedora Change
proposal https://fedoraproject.org/wiki/Changes/Pytest_8

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 marcindulak 2024-04-06 22:17:09 UTC
It should be fixed by a workaround added in this build https://koji.fedoraproject.org/koji/taskinfo?taskID=115994609,
by removing the failing tests. The latest ase upstream appears to have fixed these bugs,
but it's not released yet https://gitlab.com/ase/ase/-/milestones/4#tab-issues


Note You need to log in before you can comment on or make changes to this bug.