Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waf run_python_tests fixes #1003

Merged
merged 2 commits into from Jun 25, 2020
Merged

Conversation

palonso
Copy link
Contributor

@palonso palonso commented Jun 25, 2020

A couple of fixes for the run_python_test Waf method:

  • Replace 'is not' by '!=' for literals, which throws a warning in Python 3.8.

  • Don't overwrite PYTHONPATH when running the unit tests, so the user's required packages located in PYTHONPATH directories are correctly loaded.

This solves one of the issues described in #914

The compiler now produces a SyntaxWarning when identity checks (is and
is not) are used with certain types of literals (e.g. strings, numbers).
These can often work by accident in CPython, but are not guaranteed by
the language spec. The warning advises users to use equality tests
(== and !=) instead. (Contributed by Serhiy Storchaka in bpo-34850.)
https://bugs.python.org/issue34850
This behavior was observed when running the Python tests from Waf
(python ./waf run_python_tests)
The script creates a local Python package and sets PYTHONPATH to run the
tests ignoring existing entries
This commit proposes appending our local package to the existing
PYTHONPATH to prevent ignoring existing entries
@dbogdanov dbogdanov merged commit 8330e1b into MTG:master Jun 25, 2020
@@ -339,7 +339,7 @@ def run_python_tests(ctx):
os.system('cp -r src/python/essentia build/python/')
os.system('cp build/src/python/_essentia*.so build/python/essentia')

ret = os.system('PYTHONPATH=build/python %s test/src/unittests/all_tests.py' % sys.executable)
ret = os.system('PYTHONPATH=build/python:$PYTHONPATH %s test/src/unittests/all_tests.py' % sys.executable)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it'd be a good idea to use subprocess.run (python 3.5 and above), which takes a specific env argument, allowing us to run this without using a subshell.
Double-check that this is valid if there is a space in $PYTHONPATH

@palonso palonso deleted the run_python_tests-fix branch July 27, 2020 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants