pypa / distlib

A low-level library which implements some Python packaging standards (PEPs) and which could be used by third-party packaging tools to achieve interoperability.
http://distlib.readthedocs.io/
Other
49 stars 38 forks source link

ScriptTestCase.test_script_run fails with Python 3.13.0a3 #214

Closed befeleme closed 7 months ago

befeleme commented 7 months ago

Describe the bug

Distlib's test fails with Python 3.13.0a3. Is has run successfully with the previous alpha.

=================================== FAILURES ===================================
________________________ ScriptTestCase.test_script_run ________________________

self = <test_scripts.ScriptTestCase testMethod=test_script_run>

    def test_script_run(self):
        if sys.version_info[:2] < (3, 13):
            target = 'cgi:print_directory'
        else:
            target = 'test.support.interpreters:list_all'
        files = self.maker.make('test = %s' % target)
        self.assertEqual(len(files), 2)
        p = subprocess.Popen([sys.executable, files[0]],
                             stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        stdout, stderr = p.communicate()
        if sys.version_info[:2] < (3, 13):
            self.assertIn(b'<H3>Current Working Directory:</H3>', stdout)
            self.assertIn(os.getcwd().encode('utf-8'), stdout)
        else:
>           self.assertIn(b'[Interpreter(id=0, isolated=None)]', stderr)
E           AssertionError: b'[Interpreter(id=0, isolated=None)]' not found in b'Traceback (most recent call last):\n  File "/tmp/distlib-test-5n5zd_29/test", line 5, in <module>\n    from test.support.interpreters import list_all\nModuleNotFoundError: No module named \'test.support.interpreters\'\n'

tests/test_scripts.py:342: AssertionError
=========================== short test summary info ============================
FAILED tests/test_scripts.py::ScriptTestCase::test_script_run - AssertionErro...

To Reproduce Steps to reproduce the behavior:

  1. run tox -e py313

Environment

vsajip commented 7 months ago

Hmmm ... I get a different result, is yours reproducible?

$ PYTHONHASHSEED=0 ~/projects/cpython/main/python tests/test_all.py
............................s.................................................s....s.......s........................s.ssssss..........sss..Fs..ss.........................s..........s..........................ssss.........ss.............
======================================================================
FAIL: test_script_run (test_scripts.ScriptTestCase.test_script_run)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/disk2/vinay/projects/distlib/tests/test_scripts.py", line 343, in test_script_run
    self.assertIn(b'[Interpreter(id=0, isolated=None)]', stderr)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: b'[Interpreter(id=0, isolated=None)]' not found in b'[Interpreter(0)]\n'

----------------------------------------------------------------------
Ran 236 tests in 26.112s

FAILED (failures=1, skipped=25)

That's just a change in the textual representation, which I'll update the test to handle. I don't get the

No module named 'test.support.interpreters'

exception.

befeleme commented 7 months ago

Yes, it's consistent. Apparently, test/support/interpreters became a module in Python 3.13.0a3 and wasn't being installled: https://github.com/python/cpython/issues/115421 This will be fixed in the next alpha.