[Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest) (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Tue Jul 4 07:22:08 EDT 2017
- Previous message (by thread): [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)
- Next message (by thread): [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 4 July 2017 at 21:03, Victor Stinner <victor.stinner at gmail.com> wrote:
2017-07-04 12:52 GMT+02:00 Nick Coghlan <ncoghlan at gmail.com>:
I know it's longer, but perhaps it would make sense to put the bisection helper under "python -m test.support.bisect" in both Python 2 & 3? For me, test.support is a toolkit to write tests, not really to run tests. I don't really care where my bisect tool lives. Serhiy proposed test.bisect, I like because it's short and easy to remind. Technically it is possible to get test.bisect on Python 2, it just requires to modify 4 .py files which import Lib/bisect.py to add "from future import absoluteimport": Lib/urllib2.py:import bisect Lib/mhlib.py:from bisect import bisect Lib/test/testbisect.py:import bisect as pybisect Lib/multiprocessing/heap.py:import bisect
That doesn't sound right, as implicit relative imports in Python 2 are relative to the package (they're akin to writing "from . import name").
That means if test.bisect is shadowing the top level bisect module when backported, it suggests that the test.regrtest directory is ending up on sys.path for the affected test run (e.g. because the tests were run as "python Lib/test/regrtest.py" rather than via the -m switch).
Checking test.regrtest in 2.7, it looks to me like it's missing the stanza added to Py3 that makes sure "Lib/test/" isn't present on sys.path - if you add a similar operation to Py2.7, I'd expect the test.bisect name for the command to work there as well.
Cheers, Nick.
P.S. As far the multiprocessing failure you saw goes, my guess would be that the 2.7 version actually is relying on implicit relative imports to find peer modules, and would need some "from . import ..." adjustments to handle "from future import absolute_import" at the top of the file. However, as noted above, I don't think that's actually what's happening - I think the "Lib/test/" directory is still sometimes ending up on sys.path while running the tests in 2.7.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message (by thread): [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)
- Next message (by thread): [Python-Dev] New work-in-progress bisection tool for the Python test suite (in regrtest)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]