[issue35519] [2.7] Can not run test without test module for tests which import random module

STINNER Victor report at bugs.python.org
Mon Dec 17 10:40:12 EST 2018


STINNER Victor <vstinner at redhat.com> added the comment:

> Ah, I think because I use cpython2 directory name, you thought I used Python 2. cpython2 is just a directory name. It has nothing to do with Python 2. I used master when finding this bug.

Ah right, I can reproduce the issue in master:

vstinner at apu$ ./python Lib/test/test_xmlrpc.py 
Traceback (most recent call last):
  File "Lib/test/test_xmlrpc.py", line 8, in <module>
    import xmlrpc.client as xmlrpclib
  File "/home/vstinner/prog/python/master/Lib/xmlrpc/client.py", line 136, in <module>
    import http.client
  File "/home/vstinner/prog/python/master/Lib/http/client.py", line 71, in <module>
    import email.parser
  File "/home/vstinner/prog/python/master/Lib/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/home/vstinner/prog/python/master/Lib/email/feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "/home/vstinner/prog/python/master/Lib/email/_policybase.py", line 9, in <module>
    from email.utils import _has_surrogates
  File "/home/vstinner/prog/python/master/Lib/email/utils.py", line 28, in <module>
    import random
  File "/home/vstinner/prog/python/master/Lib/random.py", line 47, in <module>
    import bisect as _bisect
  File "/home/vstinner/prog/python/master/Lib/test/bisect.py", line 27, in <module>
    import tempfile
  File "/home/vstinner/prog/python/master/Lib/tempfile.py", line 45, in <module>
    from random import Random as _Random
ImportError: cannot import name 'Random' from 'random' (/home/vstinner/prog/python/master/Lib/random.py)

Hum. We should either rename Lib/test/bisect.py to Lib/test/bisect_cmd.py or move the feature into libregrtest.

----------
nosy: +pablogsal
resolution: fixed -> 
status: closed -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35519>
_______________________________________


More information about the Python-bugs-list mailing list