Run tests via python > 3.0 failed
Closed this issue · 4 comments
faunris commented
Test TestParsePy uses python 2.7 syntax. And this tests failed if run on python3.
martindemello commented
I could not reproduce this. How were you running the test?
$ python -m unittest tests/test_parsepy.py
.........................
----------------------------------------------------------------------
Ran 25 tests in 0.350s
OK
$ python --version
Python 3.10.0
faunris commented
New debian releases not install python2.7 by default :)
If we want deb packed this, we need exclude python2.7 dependency.
$ python2.7
-bash: python2.7: command not found
$ python3 -m unittest tests/test_parsepy.py
...
======================================================================
ERROR: test_syntax_error (tests.test_parsepy.TestParsePy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/media/psf/debian/importlab/importlab/tests/test_parsepy.py", line 217, in test_syntax_error
self.parse("foo(]")
File "/media/psf/debian/importlab/importlab/tests/test_parsepy.py", line 38, in parse
return parsepy.get_imports(f.name, self.PYTHON_VERSION)
File "/media/psf/debian/importlab/importlab/importlab/parsepy.py", line 89, in get_imports
ret, stdout, stderr = utils.run_py_file(python_version, f, filename)
File "/media/psf/debian/importlab/importlab/importlab/utils.py", line 165, in run_py_file
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib/python3.10/subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1842, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'python2.7'
----------------------------------------------------------------------
Ran 88 tests in 0.084s
FAILED (errors=24)
Test failed: <unittest.runner.TextTestResult run=88 errors=24 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=88 errors=24 failures=0>
martindemello commented
ah, i see! yes, we do rely on running python2.7 in a subprocess to parse older python code. we should indeed update that test since python2.7 is end-of-lifed.