jupyter / jupyter/nbformat

test_is_valid_should_not_mutate fails with Python 3.13

Open
#405 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
313
Forks
176
PR merge metrics
No merged PRs in 30d

Description

When packaging new version of this package for openSUSE/Factory, test test_is_valid_should_not_mutate fails:

```
[ 19s] =================================== FAILURES ===================================
[ 19s] __________ test_is_valid_should_not_mutate[_invalidator_1-jsonschema] __________
[ 19s]
[ 19s] cls =
[ 19s] func = . at 0x7fba491e0d60>
[ 19s] when = 'call'
[ 19s] reraise = (, )
[ 19s]
[ 19s] @classmethod
[ 19s] def from_call(
[ 19s] cls,
[ 19s] func: Callable[[], TResult],
[ 19s] when: Literal["collect", "setup", "call", "teardown"],
[ 19s] reraise: type[BaseException] | tuple[type[BaseException], ...] | None = None,
[ 19s] ) -> CallInfo[TResult]:
[ 19s] """Call func, wrapping the result in a CallInfo.
[ 19s]
[ 19s] :param func:
[ 19s] The function to call. Called without arguments.
[ 19s] :type func: Callable[[], _pytest.runner.TResult]
[ 19s] :param when:
[ 19s] The phase in which the function is called.
[ 19s] :param reraise:
[ 19s] Exception or exceptions that shall propagate if raised by the
[ 19s] function, instead of being wrapped in the CallInfo.
[ 19s] """
[ 19s] excinfo = None
[ 19s] start = timing.time()
[ 19s] precise_start = timing.perf_counter()
[ 19s] try:
[ 19s] > result: TResult | None = func()
[ 19s]
[ 19s] cls =
[ 19s] duration = 0.010382263993960805
[ 19s] excinfo = \n... ~~~~~~~~~~~~^^\nResourceWarning: unclosed database in \n') tblen=11>
[ 19s] func = . at 0x7fba491e0d60>
[ 19s] precise_start = 33629.259203216
[ 19s] precise_stop = 33629.26958548
[ 19s] reraise = (, )
[ 19s] result = None
[ 19s] start = 1732094445.8980231
[ 19s] stop = 1732094445.9084063
[ 19s] when = 'call'
[ 19s]
[ 19s] /usr/lib/python3.13/site-packages/_pytest/runner.py:341:
[ 19s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 19s] /usr/lib/python3.13/site-packages/_pytest/runner.py:242: in
[ 19s] lambda: runtest_hook(item=item, **kwds), when=when, reraise=reraise
[ 19s] item =
[ 19s] kwds = {}
[ 19s] runtest_hook =
[ 19s] /usr/lib/python3.13/site-packages/pluggy/_hooks.py:513: in __call__
[ 19s] return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
[ 19s] firstresult = False
[ 19s] kwargs = {'item': }
[ 19s] self =
[ 19s] /usr/lib/python3.13/site-packages/pluggy/_manager.py:120: in _hookexec
[ 19s] return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
[ 19s] firstresult = False
[ 19s] hook_name = 'pytest_runtest_call'
[ 19s] kwargs = {'item': }
[ 19s] methods = [>]
[ 19s] self = <_pytest.config.PytestPluginManager object at 0x7fba4a7602f0>
[ 19s] /usr/lib/python3.13/site-packages/_pytest/threadexception.py:92: in pytest_runtest_call
[ 19s] yield from thread_exception_runtest_hook()
[ 19s] /usr/lib/python3.13/site-packages/_pytest/threadexception.py:68: in thread_exception_runtest_hook
[ 19s] yield
[ 19s] cm = <_pytest.threadexception.catch_threading_exception object at 0x7fba4923e990>
[ 19s] /usr/lib/python3.13/site-packages/_pytest/unraisableexception.py:95: in pytest_runtest_call
[ 19s] yield from unraisable_exception_runtest_hook()
[ 19s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 19s]
[ 19s] def unraisable_exception_runtest_hook() -> Generator[None]:
[ 19s] with catch_unraisable_exception() as cm:
[ 19s] try:
[ 19s] yield
[ 19s] finally:
[ 19s] if cm.unraisable:
[ 19s] if cm.unraisable.err_msg is not None:
[ 19s] err_msg = cm.unraisable.err_msg
[ 19s] else:
[ 19s] err_msg = "Exception ignored in"
[ 19s] msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
[ 19s] msg += "".join(
[ 19s] traceback.format_exception(
[ 19s] cm.unraisable.exc_type,
[ 19s] cm.unraisable.exc_value,
[ 19s] )
[ 19s] )
[ 19s] > warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
[ 19s] E pytest.PytestUnraisableExceptionWarning: Exception ignored in:
[ 19s] E
[ 19s] E Traceback (most recent call last):
[ 19s] E File "/usr/lib/python3.13/site-packages/jsonschema/exceptions.py", line 168, in _set
[ 19s] E for k, v in kwargs.items():
[ 19s] E ~~~~~~~~~~~~^^
[ 19s] E ResourceWarning: unclosed database in
[ 19s]
[ 19s] cm = <_pytest.unraisableexception.catch_unraisable_exception object at 0x7fba4923e8d0>
[ 19s] err_msg = 'Exception ignored in'
[ 19s] msg = 'Exception ignored in: \n\nTraceback (most recent call last):\n File "/u...n ~~~~~~~~~~~~^^\nResourceWarning: unclosed database in \n'
[ 19s]
[ 19s] /usr/lib/python3.13/site-packages/_pytest/unraisableexception.py:85: PytestUnraisableExceptionWarning
[ 19s] =============================== warnings summary ===============================
[ 19s] ../../../../../usr/lib/python3.13/site-packages/jupyter_core/application.py:23
[ 19s] /usr/lib/python3.13/site-packages/jupyter_core/application.py:23: DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
[ 19s] given by the platformdirs library. To remove this warning and
[ 19s] see the appropriate new directories, set the environment variable
[ 19s] `JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
[ 19s] The use of platformdirs will be the default in `jupyter_core` v6
[ 19s] from .paths import (
[ 19s]
[ 19s] -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
[ 19s] ============================= slowest 10 durations =============================
[ 19s] 0.42s call tests/test_sign.py::TestNotary::test_sign_stdin
[ 19s] 0.04s call tests/test_validator.py::test_future[fastjsonschema]
[ 19s] 0.04s call tests/test_validator.py::test_nb2[jsonschema]
[ 19s] 0.03s call tests/test_sign.py::TestNotary::test_cull_db
[ 19s] 0.02s call tests/test_api.py::TestAPI::test_capture_validation_error
[ 19s] 0.02s call tests/test_api.py::TestAPI::test_read
[ 19s] 0.02s call tests/test_validator.py::test_future[jsonschema]
[ 19s] 0.02s call tests/test_validator.py::test_invalid_validator_raises_value_error_after_read
[ 19s] 0.02s call tests/test_validator.py::test_nb4jupyter_metadata_timings[fastjsonschema]
[ 19s] 0.02s call tests/test_validator.py::test_nb4custom[fastjsonschema]
[ 19s] =========================== short test summary info ============================
[ 19s] SKIPPED [2] tests/test_validator.py:57: Does not work in all architectures
[ 19s] FAILED tests/test_validator.py::test_is_valid_should_not_mutate[_invalidator_1-jsonschema]
[ 19s] ============= 1 failed, 185 passed, 2 skipped, 1 warning in 1.28s ==============
```

[Complete build log](https://github.com/user-attachments/files/17828254/_log.txt) with the list of all packages used and steps taken to reproduce the problem. Notice, that whole test suite passes with 3.10 and 3.12.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.