Bug 2245281 - python-distlib fails to build with Python 3.13: ScriptTestCase.test_script_run fails (unexpected empty stdout of subprocess, possibly related to missing cgi module)
Summary: python-distlib fails to build with Python 3.13: ScriptTestCase.test_script_ru...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: python-distlib
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miro Hrončok
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.13
TreeView+ depends on / blocked
 
Reported: 2023-10-20 13:52 UTC by Karolina Surma
Modified: 2023-11-29 13:12 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2023-11-29 13:12:49 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Fedora Package Sources python-distlib pull-request 17 0 None None None 2023-11-22 12:22:29 UTC
Github pypa distlib issues 208 0 None open Test issues with Python 3.13 2023-10-23 11:26:15 UTC

Description Karolina Surma 2023-10-20 13:52:01 UTC
python-distlib fails to build with Python 3.13.0a1.

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

The test fails:

________________________ ScriptTestCase.test_script_run ________________________

self = <test_scripts.ScriptTestCase testMethod=test_script_run>

    def test_script_run(self):
        files = self.maker.make('test = cgi:print_directory')
        self.assertEqual(len(files), 2)
        p = subprocess.Popen([sys.executable, files[0]],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
>       self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
E       AssertionError: b'<H3>Current Working Directory:</H3>' not found in b''

tests/test_scripts.py:334: AssertionError
=========================== short test summary info ============================
FAILED tests/test_scripts.py::ScriptTestCase::test_script_run - AssertionErro...
===== 1 failed, 200 passed, 34 skipped, 3 deselected, 3 warnings in 10.58s =====


For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06550785-python-distlib/

For all our attempts to build python-distlib with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-distlib/

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

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41. To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
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 Miro Hrončok 2023-10-20 13:59:12 UTC
For the record, the original test failures are:

________________________ ScriptTestCase.test_script_run ________________________

self = <test_scripts.ScriptTestCase testMethod=test_script_run>

    def test_script_run(self):
        files = self.maker.make('test = cgi:print_directory')
        self.assertEqual(len(files), 2)
        p = subprocess.Popen([sys.executable, files[0]],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
>       self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
E       AssertionError: b'<H3>Current Working Directory:</H3>' not found in b''

tests/test_scripts.py:334: AssertionError
__________________________________ test_suite __________________________________

    def test_suite():
        #README = os.path.join(os.path.dirname(__file__), 'README.txt')
        #suite = [doctest.DocFileSuite(README), unittest.makeSuite(VersionTestCase)]
>       suite = [unittest.makeSuite(VersionTestCase),
                 unittest.makeSuite(CompatibilityTestCase),
                 unittest.makeSuite(LegacyVersionTestCase),
                 unittest.makeSuite(SemanticVersionTestCase)]

tests/test_version.py:648: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

name = 'makeSuite'

    def __getattr__(name):
        if name == 'IsolatedAsyncioTestCase':
            global IsolatedAsyncioTestCase
            from .async_case import IsolatedAsyncioTestCase
            return IsolatedAsyncioTestCase
>       raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
E       AttributeError: module 'unittest' has no attribute 'makeSuite'

/usr/lib64/python3.13/unittest/__init__.py:80: AttributeError



However, test_suite is not a test. Upstream does not use pytest, they use unittest and they have a function called test_suite which is used to "prepare" the test suite. It uses functions removed from unittest in Python 3.13. pytest collects this function as a test (due to the name of the function), executes it and it normally succeeds (there are no asserts). However now it fails.

While this probably needs to be addressed upstream, a simple workaround was to deselect the non-test.


-------------


The actual failure here is test_script_run. I belive that the called subprocess fails (the call does not check that) and the error is in stderr (the test does not display that). Possibly related to the missing cgi module.

Comment 2 Miro Hrončok 2023-10-23 11:18:27 UTC
I believe the test is using the cgi module only as a convenient way to test running a script created by ScriptMaker.make().

As such, skipping it for now in copr.

Comment 3 Miro Hrončok 2023-10-23 11:26:16 UTC
Reported upstream https://github.com/pypa/distlib/issues/208

Comment 4 Miro Hrončok 2023-10-24 12:01:00 UTC
And fixed upstream https://github.com/pypa/distlib/commit/e27569b02d9718c19ece71ce6d5124b967277399

Comment 5 Miro Hrončok 2023-11-22 12:22:29 UTC
A downstream backport: https://src.fedoraproject.org/rpms/python-distlib/pull-request/17


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