This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients quentel, serhiy.storchaka, vstinner, yselivanov
Date 2017-07-25.09:07:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500973646.36.0.201073519509.issue29512@psf.upfronthosting.co.za>
In-reply-to
Content
Workarounds:

* ./python -m test test_httpservers
* ./python -I Lib/test/test_httpservers.py

> Maybe it's me who is doing things wrong, but when I run Lib/test/test_httpservers.py I get this strange error :

...
  File "c:\python36\lib\random.py", line 48, in <module>
    import bisect as _bisect
  File "C:\cpython\Lib\test\bisect.py", line 27, in <module>
...

Oh. Lib/test/ should not be in sys.path. "import bisect" loaded Lib/test/bisect.py instead of Lib/bisect.py. See my commit 3050987d85d7cf8cdd4b3c053e673d13cd8dfb12 in Python 2.7:

    * regrtest now removes '' and Lib/test/ from sys.path
    * Use absolute import in test_bisect

(regrtest in master already does something similar.)

But the sys.path is only fixed when regrtest is used...


> There are many ways of running tests, and some of them are broken now.
> $ ./python Lib/test/test_bisect.py

... if you run Lib/test/test_xxx.py directly, Lib/test/ is added to sys.path, except if you use -I:

$ ./python -I Lib/test/test_bisect.py 
....................................
----------------------------------------------------------------------
Ran 36 tests in 0.094s

OK


I didn't know that "./python Lib/test/test_bisect.py" was broken :-(

Maybe Lib/test/support/__init__.py can remove Lib/test/ from sys.path?

Another option is to move or rename Lib/test/bisect.py. For example, replace "./python -m test.bisect ..." with "./python -m test bisect ..." (or maybe "./python -m test --bisect ..."). The problem is that bisect has extra options, but we can add a bisect prefix to these options.

I reopen this issue.
History
Date User Action Args
2017-07-25 09:07:26vstinnersetrecipients: + vstinner, quentel, serhiy.storchaka, yselivanov
2017-07-25 09:07:26vstinnersetmessageid: <1500973646.36.0.201073519509.issue29512@psf.upfronthosting.co.za>
2017-07-25 09:07:26vstinnerlinkissue29512 messages
2017-07-25 09:07:26vstinnercreate