-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework utopya test invocation to support process spawning
The pytest framework seems to have its troubles with multiprocessing. Prior to this commit, running `test_task.py` individually would succeed, while running the whole test suite would fail, just as one example. This commit addresses those issues by wrapping `pytest.main` execution into the `if __name__ == '__main__'` guard and ensuring that the utopya module is in the system path (regardless of how pytest may have modified it). See pytest-dev/pytest#958 for more info.
- Loading branch information
Showing
4 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/python3 | ||
"""This is a custom entrypoint to pytest which takes care that pytest is | ||
run within the ``if __name__ == '__main__'`` guard, thereby resolving issues | ||
with the multiprocessing module. | ||
We are not the only ones with this problem, see: | ||
- https://github.com/pytest-dev/pytest/issues/958 | ||
- https://github.com/web-platform-tests/wpt/issues/24880 | ||
""" | ||
|
||
import os | ||
import sys | ||
|
||
import pytest | ||
|
||
# Ensure that utopya is in the path and already imported at this point. If not | ||
# doing this, discovery of the utopya module may fail if the test modules are | ||
# imported when *spawning* a new multiprocessing.Process ... | ||
sys.path.insert(0, os.path.dirname(__file__)) | ||
import utopya | ||
|
||
if __name__ == '__main__': | ||
sys.exit(pytest.main([__file__] + sys.argv[1:])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters