Bug 2026355 - python-icalendar fails to build with Python 3.11: AttributeError: 'IcalendarTestCase' object has no attribute 'assertRaisesRegexp'
Summary: python-icalendar fails to build with Python 3.11: AttributeError: 'IcalendarT...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-icalendar
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Gwyn Ciesla
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.11
TreeView+ depends on / blocked
 
Reported: 2021-11-24 12:41 UTC by Tomáš Hrnčiar
Modified: 2022-01-26 15:02 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-26 15:02:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github collective icalendar issues 344 0 None open Test failure on Python 3.11 2022-01-12 15:33:10 UTC

Description Tomáš Hrnčiar 2021-11-24 12:41:19 UTC
python-icalendar fails to build with Python 3.11.0a2.

=================================== FAILURES ===================================
___________________ IcalendarTestCase.test_contentline_class ___________________

self = <icalendar.tests.test_icalendar.IcalendarTestCase testMethod=test_contentline_class>

    def test_contentline_class(self):
        from ..parser import Contentline, Parameters
        from ..prop import vText
    
        self.assertEqual(
            Contentline('Si meliora dies, ut vina, poemata reddit').to_ical(),
            b'Si meliora dies, ut vina, poemata reddit'
        )
    
        # A long line gets folded
        c = Contentline(''.join(['123456789 '] * 10)).to_ical()
        self.assertEqual(
            c,
            (b'123456789 123456789 123456789 123456789 123456789 123456789 '
             b'123456789 1234\r\n 56789 123456789 123456789 ')
        )
    
        # A folded line gets unfolded
        self.assertEqual(
            Contentline.from_ical(c),
            ('123456789 123456789 123456789 123456789 123456789 123456789 '
             '123456789 123456789 123456789 123456789 ')
        )
    
        # http://tools.ietf.org/html/rfc5545#section-3.3.11
        # An intentional formatted text line break MUST only be included in
        # a "TEXT" property value by representing the line break with the
        # character sequence of BACKSLASH, followed by a LATIN SMALL LETTER
        # N or a LATIN CAPITAL LETTER N, that is "\n" or "\N".
    
        # Newlines are not allwoed in content lines
        self.assertRaises(AssertionError, Contentline, b'1234\r\n\r\n1234')
    
        self.assertEqual(
            Contentline('1234\\n\\n1234').to_ical(),
            b'1234\\n\\n1234'
        )
    
        # We do not fold within a UTF-8 character
        c = Contentline(b'This line has a UTF-8 character where it should be '
                        b'folded. Make sure it g\xc3\xabts folded before that '
                        b'character.')
    
        self.assertIn(b'\xc3\xab', c.to_ical())
    
        # Another test of the above
        c = Contentline(b'x' * 73 + b'\xc3\xab' + b'\\n ' + b'y' * 10)
    
        self.assertEqual(c.to_ical().count(b'\xc3'), 1)
    
        # Don't fail if we fold a line that is exactly X times 74 characters
        # long
        c = Contentline(''.join(['x'] * 148)).to_ical()
    
        # It can parse itself into parts,
        # which is a tuple of (name, params, vals)
        self.assertEqual(
            Contentline('dtstart:20050101T120000').parts(),
            ('dtstart', Parameters({}), '20050101T120000')
        )
    
        self.assertEqual(
            Contentline('dtstart;value=datetime:20050101T120000').parts(),
            ('dtstart', Parameters({'VALUE': 'datetime'}), '20050101T120000')
        )
    
        c = Contentline('ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:'
                        'maxm')
        self.assertEqual(
            c.parts(),
            ('ATTENDEE',
             Parameters({'ROLE': 'REQ-PARTICIPANT', 'CN': 'Max Rasmussen'}),
             'maxm')
        )
        self.assertEqual(
            c.to_ical().decode('utf-8'),
            'ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:'
            'maxm'
        )
    
        # and back again
        # NOTE: we are quoting property values with spaces in it.
        parts = ('ATTENDEE',
                 Parameters({'ROLE': 'REQ-PARTICIPANT',
                             'CN': 'Max Rasmussen'}),
                 'maxm')
        self.assertEqual(
            Contentline.from_parts(*parts),
            'ATTENDEE;CN="Max Rasmussen";ROLE=REQ-PARTICIPANT:'
            'maxm'
        )
    
        # and again
        parts = ('ATTENDEE', Parameters(), 'maxm')
        self.assertEqual(
            Contentline.from_parts(*parts),
            'ATTENDEE:maxm'
        )
    
        # A value can also be any of the types defined in PropertyValues
        parts = ('ATTENDEE', Parameters(), vText('test'))
        self.assertEqual(
            Contentline.from_parts(*parts),
            'ATTENDEE:test'
        )
    
        # A value in UTF-8
        parts = ('SUMMARY', Parameters(), vText('INternational char æ ø å'))
        self.assertEqual(
            Contentline.from_parts(*parts),
            'SUMMARY:INternational char æ ø å'
        )
    
        # A value can also be unicode
        parts = ('SUMMARY', Parameters(), vText('INternational char æ ø å'))
        self.assertEqual(
            Contentline.from_parts(*parts),
            'SUMMARY:INternational char æ ø å'
        )
    
        # Traversing could look like this.
        name, params, vals = c.parts()
        self.assertEqual(name, 'ATTENDEE')
        self.assertEqual(vals, 'maxm')
        self.assertEqual(
            sorted(params.items()),
            sorted([('ROLE', 'REQ-PARTICIPANT'), ('CN', 'Max Rasmussen')])
        )
    
        # And the traditional failure
>       with self.assertRaisesRegexp(
            ValueError,
            'Content line could not be parsed into parts'
        ):
E       AttributeError: 'IcalendarTestCase' object has no attribute 'assertRaisesRegexp'

src/icalendar/tests/test_icalendar.py:168: AttributeError
=========================== short test summary info ============================
FAILED src/icalendar/tests/test_icalendar.py::IcalendarTestCase::test_contentline_class
========================= 1 failed, 95 passed in 0.45s =========================

Removed many old deprecated unittest features:
    TestCase method aliases failUnlessEqual, failIfEqual, failUnless, failIf, failUnlessRaises, failUnlessAlmostEqual, failIfAlmostEqual (deprecated in Python 3.1), assertEquals, assertNotEquals, assert_, assertAlmostEquals, assertNotAlmostEquals, assertRegexpMatches, assertRaisesRegexp (deprecated in Python 3.2), and assertNotRegexpMatches (deprecated in Python 3.5).
    Undocumented and broken TestCase method assertDictContainsSubset (deprecated in Python 3.2).
    Undocumented <unittest.TestLoader.loadTestsFromModule> TestLoader.loadTestsFromModule() parameter use_load_tests (deprecated and ignored since Python 3.2).
    An alias of the TextTestResult class: _TextTestResult (deprecated in Python 3.2).

(Contributed by Serhiy Storchaka in bpo-45162.)

https://bugs.python.org/issue45162
https://docs.python.org/3.11/whatsnew/3.11.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.11/fedora-rawhide-x86_64/02984981-python-icalendar/

For all our attempts to build python-icalendar with Python 3.11, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/package/python-icalendar/

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.11:
https://copr.fedorainfracloud.org/coprs/g/python/python3.11/

Let us know here if you have any questions.

Python 3.11 is planned to be included in Fedora 37. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.11.
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.


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