mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
dev_scripts: Fix a recursion issue in our PyTest wrapper
Fix an issue in our PyTest wrapper, that caused this recursion error: ``` File "shibokensupport/signature/loader.py", line 61, in feature_importedgc File "shibokensupport/feature.py", line 137, in feature_importedgc File "shibokensupport/feature.py", line 148, in _mod_uses_pysidegc File "/usr/lib/python3.10/inspect.py", line 1147, in getsourcegc lines, lnum = getsourcelines(object)gc File "/usr/lib/python3.10/inspect.py", line 1129, in getsourcelinesgc lines, lnum = findsource(object)gc File "/usr/lib/python3.10/inspect.py", line 954, in findsourcegc lines = linecache.getlines(file, module.__dict__)gc File "/home/user/.cache/pypoetry/virtualenvs/dangerzone-hQU0mwlP-py3.10/lib/python3.10/site-packages/py/_vendored_packages/apipkg/__init__.py", line 177, in __dict__gc self.__makeattr(name)gc File "/home/user/.cache/pypoetry/virtualenvs/dangerzone-hQU0mwlP-py3.10/lib/python3.10/site-packages/py/_vendored_packages/apipkg/__init__.py", line 157, in __makeattrgc result = importobj(modpath, attrname)gc File "/home/user/.cache/pypoetry/virtualenvs/dangerzone-hQU0mwlP-py3.10/lib/python3.10/site-packages/py/_vendored_packages/apipkg/__init__.py", line 75, in importobjgc module = __import__(modpath, None, None, ["__doc__"])gc File "shibokensupport/signature/loader.py", line 54, in feature_importgc RecursionError: maximum recursion depth exceededgc ``` This error seems to be related to https://github.com/pytest-dev/pytest/issues/1794. By not importing `pytest` in our test wrapper, and instead executing directly, we can avoid it. Note that this seems to be triggered only by Shiboken6, which is why we hadn't previously encountered it.
This commit is contained in:
parent
89e8b998d6
commit
e7eb3bf18b
1 changed files with 11 additions and 4 deletions
|
@ -14,7 +14,6 @@ import re
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from pkg_resources import parse_version
|
||||
|
||||
from dangerzone.isolation_provider.container import Container
|
||||
|
@ -30,14 +29,22 @@ def get_podman_version():
|
|||
return version.split("-dev")[0] # exclude "-dev" suffix from version
|
||||
|
||||
|
||||
def run_tests(pytest_args):
|
||||
cmd = ["pytest"] + pytest_args
|
||||
try:
|
||||
subprocess.run(cmd, check=True)
|
||||
except subprocess.CalledProcessError:
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def run_tests_in_parallel(pytest_args):
|
||||
args = pytest_args + ["-n", "4"]
|
||||
exit_code = pytest.main(args)
|
||||
print("running tests in parallel")
|
||||
run_tests(pytest_args + ["-n", "4"])
|
||||
|
||||
|
||||
def run_tests_in_sequence(pytest_args):
|
||||
print("running tests sequentially")
|
||||
exit_code = pytest.main(pytest_args)
|
||||
run_tests(pytest_args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue