Log
```
=========================== test session starts ============================
platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0
rootdir: /private/tmp
collected 471 items / 1 skipped
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py . [ 0%]
...................xxsssssssssss.ss................................. [ 14%]
....................................................s............... [ 29%]
.....................................F....................ssss...... [ 43%]
............................................... [ 53%]
.venv/lib/python3.12/site-packages/unyt/tests/test_define_unit.py .. [ 53%]
[ 53%]
.venv/lib/python3.12/site-packages/unyt/tests/test_mpl_interface.py s [ 54%]
sssssssssssssss [ 57%]
.venv/lib/python3.12/site-packages/unyt/tests/test_no_duplicates.py . [ 57%]
[ 57%]
.venv/lib/python3.12/site-packages/unyt/tests/test_unit_registry.py . [ 57%]
......... [ 59%]
.venv/lib/python3.12/site-packages/unyt/tests/test_unit_systems.py . [ 59%]
...... [ 61%]
.venv/lib/python3.12/site-packages/unyt/tests/test_units.py ........ [ 62%]
.......................................... [ 71%]
.venv/lib/python3.12/site-packages/unyt/tests/test_unyt_array.py ... [ 72%]
.........x.......sss....s........................................... [ 86%]
..................................................... [ 98%]
.venv/lib/python3.12/site-packages/unyt/tests/test_unyt_testing.py . [ 98%]
........ [100%]
================================= FAILURES =================================
_______________________________ test_savetxt _______________________________
tmp_path = PosixPath('/private/var/folders/47/t9k4zdz96vzd4v1rxyv07nvh0000gn/T/pytest-of-clm/pytest-16/test_savetxt0')
def test_savetxt(tmp_path):
a = [1, 2, 3] * cm
> with pytest.raises(
UserWarning,
match=re.escape(
"numpy.savetxt does not preserve units, "
"and will only save the raw numerical data from the unyt_array object.\n"
"If this is the intended behaviour, call `numpy.savetxt(file, arr.d)` "
"to silence this warning.\n"
"If you want to preserve units, use `unyt.savetxt` "
"(and `unyt.loadtxt`) instead."
),
):
E Failed: DID NOT RAISE
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:1407: Failed
============================= warnings summary =============================
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function mirr was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function mirr was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function irr was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function irr was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function npv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function npv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function pmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function pmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function nper was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function nper was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function ipmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function ipmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function ppmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function ppmt was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function rate was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function rate was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function fv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function fv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:214: DeprecationWarning: In accordance with NEP 32, the function pv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
if hasattr(np, func):
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215
/private/tmp/.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py:215: DeprecationWarning: In accordance with NEP 32, the function pv was removed from NumPy version 1.20. A replacement for this function is available in the numpy_financial library: https://pypi.org/project/numpy-financial
NOT_HANDLED_FUNCTIONS.add(getattr(np, func))
.venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py::test_savetxt
/private/tmp/.venv/lib/python3.12/site-packages/_pytest/python.py:195: UserWarning: numpy.savetxt does not preserve units, and will only save the raw numerical data from the unyt_array object.
If this is the intended behaviour, call `numpy.savetxt(file, arr.d)` to silence this warning.
If you want to preserve units, use `unyt.savetxt` (and `unyt.loadtxt`) instead.
result = testfunction(**testargs)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================= short test summary info ==========================
FAILED .venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py::test_savetxt - Failed: DID NOT RAISE
==== 1 failed, 429 passed, 39 skipped, 3 xfailed, 21 warnings in 1.37s =====
```
further details:
this still happens if I downgrade pytest (8.1.1 is known to cause issues so I checked)
the failing test reports that a warning didn't go off, but the very same warning is still reported in logs
there are multiple other warnings that we usually don't see in CI (because they are explicitly filtered in pytest configuration, stored in pyproject.toml)
I manually checked that the piece of code under test actually behaved as intended in the same environment
All these clues lead me to believe that this was purely a testing defect, not an actual bug, so I still pushed the release as is on PyPI. However I'd like to fix it for next time.
I think what may be happening is that the success of the test suite is dependent on our exact pytest configuration, which is apparently lost in packaging, but I need to inspect this more closely.
Description
This is to keep track of an issue I faced in the process of releasing uny 3.0.2, where I found that one test would fail when running in isolation.
What I Did
Log
``` =========================== test session starts ============================ platform darwin -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0 rootdir: /private/tmp collected 471 items / 1 skipped .venv/lib/python3.12/site-packages/unyt/tests/test_array_functions.py . [ 0%] ...................xxsssssssssss.ss................................. [ 14%] ....................................................s............... [ 29%] .....................................F....................ssss...... [ 43%] ............................................... [ 53%] .venv/lib/python3.12/site-packages/unyt/tests/test_define_unit.py .. [ 53%] [ 53%] .venv/lib/python3.12/site-packages/unyt/tests/test_mpl_interface.py s [ 54%] sssssssssssssss [ 57%] .venv/lib/python3.12/site-packages/unyt/tests/test_no_duplicates.py . [ 57%] [ 57%] .venv/lib/python3.12/site-packages/unyt/tests/test_unit_registry.py . [ 57%] ......... [ 59%] .venv/lib/python3.12/site-packages/unyt/tests/test_unit_systems.py . [ 59%] ...... [ 61%] .venv/lib/python3.12/site-packages/unyt/tests/test_units.py ........ [ 62%] .......................................... [ 71%] .venv/lib/python3.12/site-packages/unyt/tests/test_unyt_array.py ... [ 72%] .........x.......sss....s........................................... [ 86%] ..................................................... [ 98%] .venv/lib/python3.12/site-packages/unyt/tests/test_unyt_testing.py . [ 98%] ........ [100%] ================================= FAILURES ================================= _______________________________ test_savetxt _______________________________ tmp_path = PosixPath('/private/var/folders/47/t9k4zdz96vzd4v1rxyv07nvh0000gn/T/pytest-of-clm/pytest-16/test_savetxt0') def test_savetxt(tmp_path): a = [1, 2, 3] * cm > with pytest.raises( UserWarning, match=re.escape( "numpy.savetxt does not preserve units, " "and will only save the raw numerical data from the unyt_array object.\n" "If this is the intended behaviour, call `numpy.savetxt(file, arr.d)` " "to silence this warning.\n" "If you want to preserve units, use `unyt.savetxt` " "(and `unyt.loadtxt`) instead." ), ): E Failed: DID NOT RAISEfurther details:
pyproject.toml
)All these clues lead me to believe that this was purely a testing defect, not an actual bug, so I still pushed the release as is on PyPI. However I'd like to fix it for next time.
I think what may be happening is that the success of the test suite is dependent on our exact pytest configuration, which is apparently lost in packaging, but I need to inspect this more closely.