ipyparallel ftbfs with Python 3.12 as default

Bug #2052727 reported by Chris Peterson
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ipyparallel (Debian)
New
Unknown
ipyparallel (Ubuntu)
Fix Released
Undecided
Graham Inggs

Bug Description

Imported from Debian bug http://bugs.debian.org/1061744:

Package: src:ipyparallel
Version: 7.1.0-5
Severity: serious
Tags: sid trixie ftbfs
User: <email address hidden>
Usertags: python3.12

With python3-defaults from experimental, the package fails to build:

[...]
=================================== FAILURES
===================================
_____________________________ test_disambiguate_ip
_____________________________

warn_mock = <MagicMock name='warn' id='140702045868912'>

     @mock.patch('warnings.warn')
     def test_disambiguate_ip(warn_mock):
         # garbage in, garbage out
         assert util.disambiguate_ip_address('garbage') == 'garbage'
         assert util.disambiguate_ip_address('0.0.0.0',
socket.gethostname()) == localhost()
         wontresolve = 'this.wontresolve.dns'
         assert util.disambiguate_ip_address('0.0.0.0', wontresolve) ==
wontresolve
         assert warn_mock.called_once_with(
             'IPython could not determine IPs for {}: '
             '[Errno -2] Name or service not known'.format(wontresolve),
             RuntimeWarning,
 > )

ipyparallel/tests/test_util.py:21:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _

self = <MagicMock name='warn' id='140702045868912'>, name =
'called_once_with'

     def __getattr__(self, name):
         if name in {'_mock_methods', '_mock_unsafe'}:
             raise AttributeError(name)
         elif self._mock_methods is not None:
             if name not in self._mock_methods or name in _all_magics:
                 raise AttributeError("Mock object has no attribute %r"
% name)
         elif _is_magic(name):
             raise AttributeError(name)
         if not self._mock_unsafe and (not self._mock_methods or name
not in self._mock_methods):
             if name.startswith(('assert', 'assret', 'asert', 'aseert',
'assrt')) or name in _ATTRIB_DENY_LIST:
 > raise AttributeError(
                     f"{name!r} is not a valid assertion. Use a spec "
                     f"for the mock if {name!r} is meant to be an
attribute.")
E AttributeError: 'called_once_with' is not a valid
assertion. Use a spec for the mock if 'called_once_with' is meant to be
an attribute.. Did you mean: 'assert_called_once_with'?

/usr/lib/python3.12/unittest/mock.py:663: AttributeError

Chris Peterson (cpete)
Changed in ipyparallel (Ubuntu):
assignee: nobody → Chris Peterson (cpete)
tags: added: update-excuse
Changed in ipyparallel (Debian):
importance: Undecided → Unknown
Revision history for this message
Chris Peterson (cpete) wrote :
Changed in ipyparallel (Ubuntu):
assignee: Chris Peterson (cpete) → nobody
status: New → In Progress
Graham Inggs (ginggs)
Changed in ipyparallel (Ubuntu):
assignee: nobody → Graham Inggs (ginggs)
Revision history for this message
Graham Inggs (ginggs) wrote (last edit ):

It looks like there's a typo in your patch, not sure how it passed:

+- assert warn_mock.called_once_with(
++ warn_mock.asset_called_once_with(

I guess that should be "assert_called_once_with".

I noticed your test was run with:

324s ============================= test session starts ==============================
324s platform linux -- Python 3.11.7, pytest-7.4.4, pluggy-1.3.0
324s rootdir: /usr/lib/python3/dist-packages/ipyparallel

For fixes involving a transition, I usually trigger the autopkgtests twice, the second time with &all-proposed=1. I did so in your PPA, and it still passed, with:

276s ============================= test session starts ==============================
276s platform linux -- Python 3.12.2, pytest-7.4.4, pluggy-1.4.0
276s rootdir: /usr/lib/python3/dist-packages/ipyparallel

https://autopkgtest.ubuntu.com/results/autopkgtest-noble-cpete-ipyparallel/noble/amd64/i/ipyparallel/20240209_075236_45a54@/log.gz

Revision history for this message
Graham Inggs (ginggs) wrote :

I tested in my own PPA with the typo fixed, and it still passes with Python 3.11 and 3.12. So will upload that.

Graham Inggs (ginggs)
Changed in ipyparallel (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ipyparallel - 7.1.0-5ubuntu1

---------------
ipyparallel (7.1.0-5ubuntu1) noble; urgency=medium

  * Fix tests for python3.12 (LP: #2052727)

 -- Chris Peterson <email address hidden> Thu, 08 Feb 2024 10:44:16 -0800

Changed in ipyparallel (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Chris Peterson (cpete) wrote :

Thanks for catching that! Usually my work flow is to make the functional changes and test in a ppa and then edit the headers and do a source build once it's ready to go. I must've typo'd that in the process but I'm not sure how.

Also good note about the autopkgtest triggers.

Anyways, thanks for the sponsor!

Revision history for this message
Graham Inggs (ginggs) wrote :

You are welcome!

What I find really weird is that your PPA upload has the same typo, yet the tests passed there.

Revision history for this message
Chris Peterson (cpete) wrote (last edit ):

Hah. Fixed a typo which passed with the same issue as before:

>>> from unittest import mock
>>> my_mock = mock.Mock()
>>> bool(my_mock.asset_called_once_with())
True

mocks objects evaluate to true!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.