weixin_39822993 2020-11-30 11:25
浏览 0

Running tests with Python 3.2.1

Originally reported on Google Code with ID 51


The attached patch fixes iwyu_test_util.py to run with Python 3.2.1. It also addresses
a couple of Windows-specific issues.

Whilst I do't expect this to be committed (I expect you might be targetting an older
version of Python?) it might be useful for anyone having problems running the tests.
If it's useful I can update the Wiki with a link to this issue.

The fixes are:

lines 42-43) Windows needs to normalise dir separators and look for '.exe'
line 71) Windows can't set close_fds=True and redirect stdout/stderr
line 72) With Python 3, the process output is treated as a bytes and needs to be decoded
as utf-8 before it can be treated as a string
lines 205-206, 216) Fix a warning about leaking file handles (Python3? Related to close_fds
change above?)
line 331) With Python 3, generator.next() becomes next(generator)
lines 365, 367) With Python 3, 'print x' becomes 'print(x)'
line 381) assert_ is deprecated and should be replaced with assertTrue





Reported by paul.holden on 2011-07-16 14:10:33

该提问来源于开源项目:include-what-you-use/include-what-you-use

  • 写回答

16条回答 默认 最新

  • weixin_39822993 2020-11-30 11:25
    关注
    
    Nice!  I don't even have python3 installed, so haven't thought to test on it.
    
    In general, I'm happy to make any changes to support python3, that continue to work
    on python2.  The only one I'm not sure about is the replacement of x.next() with next(x).
    
    Do you have a python2 interpreter handy to test on?  If next(x) works there, feel free
    to apply all of these fixes.  If not, let's figure out a way to get that to work on
    both python2 and python3, that's not too ugly.
    
    According to http://diveintopython3.org/porting-code-to-python-3-with-2to3.html#next,
    python3 still supports the next method(), so the change to next(generator) isn't actually
    necessary.  Is that no longer true? 
    

    Reported by csilvers on 2011-07-18 23:42:31

    评论

报告相同问题?