Bug 2192552 - python-qrcode fails to build with Python 3.12: AttributeError: 'has_calls' is not a valid assertion. Use a spec for the mock if 'has_calls' is meant to be an attribute.
Summary: python-qrcode fails to build with Python 3.12: AttributeError: 'has_calls' is...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-qrcode
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.12
TreeView+ depends on / blocked
 
Reported: 2023-05-02 09:16 UTC by Tomáš Hrnčiar
Modified: 2023-05-12 12:19 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-05-12 12:19:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Tomáš Hrnčiar 2023-05-02 09:16:39 UTC
python-qrcode fails to build with Python 3.12.0a7.

=================================== FAILURES ===================================
________________________ UpdateManpageTests.test_change ________________________

self = <qrcode.tests.test_release.UpdateManpageTests testMethod=test_change>
mock_file = <MagicMock name='open' id='140152631746944'>

    @mock.patch(OPEN, new_callable=mock.mock_open, read_data=DATA)
    def test_change(self, mock_file):
        update_manpage({"name": "qrcode", "new_version": "3.11"})
        expected = re.split(r"([^\n]*(?:\n|$))", DATA)[1::2]
        expected[1] = (
            expected[1]
            .replace("version", "3.11")
            .replace("date", datetime.datetime.now().strftime("%-d %b %Y"))
        )
>       mock_file().write.has_calls([mock.call(line) for line in expected])

qrcode/tests/test_release.py:40: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <MagicMock name='open().write' id='140152663973936'>, name = 'has_calls'

    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: 'has_calls' is not a valid assertion. Use a spec for the mock if 'has_calls' is meant to be an attribute.


https://docs.python.org/3.12/whatsnew/3.12.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.12/fedora-rawhide-x86_64/05864365-python-qrcode/

For all our attempts to build python-qrcode with Python 3.12, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/package/python-qrcode/

Testing and mass rebuild of packages is happening in copr. You can follow these instructions to test locally in mock if your package builds with Python 3.12:
https://copr.fedorainfracloud.org/coprs/g/python/python3.12/

Let us know here if you have any questions.

Python 3.12 is planned to be included in Fedora 39. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.12.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires), so if this package is required a lot, it's important for us to get it fixed soon.
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 Sandro Mani 2023-05-12 12:19:37 UTC
Fixed in python-qrcode-7.4.2-3.fc39.


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